PC Review


Reply
Thread Tools Rate Thread

Error with Shell Function

 
 
Kevin Webb
Guest
Posts: n/a
 
      4th Aug 2003
I hope someone can help me figure this out. I have the
following code attached to a command button:

Dim stAppName As String
Dim strFileName As String

'Turn Warnings and MsgBoxes off
DoCmd.SetWarnings (0)

'Set variables for application name and file name/path
stAppName = "Excel.exe"
strFileName = "c:\Downloads\Domestic_Samples.xls"

'Open Excel file through use of Shell command
Call Shell(stAppName & " " & Chr(34) & strFileName &
Chr(34), 1)

It runs fine on my work PC and also another test PC. On
two other PC's, it is returning a "File Not Found" error.
I have not been able to recreate the error on any PC's I
have available, so I am at a loss as to why this is
occuring. If I can't fix this, I can't use it, so any
help is greatly appreciated.

BTW: This is in Access 97 on Windows NT boxes.

Thanks
Kevin Webb
United Parcel Service
 
Reply With Quote
 
 
 
 
TC
Guest
Posts: n/a
 
      4th Aug 2003
Who is saying "file not found"? (Access, Windows, Excel)

Does "c:\Downloads\Domestic_Samples.xls" exists on the PCs where the error
occurs?

What does this display if you put it immediately before the Call Shell:
msgbox ">" & strfilename & "<" & vbcrlf & ">" & dir(strfilename) & "<"

BTW, you dont need the brackets around the SetWarning parameter.
-ok: DoSomething 99
-ok: Call DoSomething (99)

'DoSomething (99)' has a side-effect that will not affect what you're
doing, but is unnecessary.

HTH,
TC



"Kevin Webb" <(E-Mail Removed)> wrote in message
news:0f5c01c35a27$34d49fc0$(E-Mail Removed)...
> I hope someone can help me figure this out. I have the
> following code attached to a command button:
>
> Dim stAppName As String
> Dim strFileName As String
>
> 'Turn Warnings and MsgBoxes off
> DoCmd.SetWarnings (0)
>
> 'Set variables for application name and file name/path
> stAppName = "Excel.exe"
> strFileName = "c:\Downloads\Domestic_Samples.xls"
>
> 'Open Excel file through use of Shell command
> Call Shell(stAppName & " " & Chr(34) & strFileName &
> Chr(34), 1)
>
> It runs fine on my work PC and also another test PC. On
> two other PC's, it is returning a "File Not Found" error.
> I have not been able to recreate the error on any PC's I
> have available, so I am at a loss as to why this is
> occuring. If I can't fix this, I can't use it, so any
> help is greatly appreciated.
>
> BTW: This is in Access 97 on Windows NT boxes.
>
> Thanks
> Kevin Webb
> United Parcel Service



 
Reply With Quote
 
Heiko
Guest
Posts: n/a
 
      4th Aug 2003
Hello Kevin,
think you should proof for an existing PATH-Variable for Excel
or add the Full Path to the Command.
Try
Start - Run - Excel.exe to check this.
Heiko
:-)
"Kevin Webb" <(E-Mail Removed)> wrote:

>I hope someone can help me figure this out. I have the
>following code attached to a command button:
>
> Dim stAppName As String
> Dim strFileName As String
>
> 'Turn Warnings and MsgBoxes off
> DoCmd.SetWarnings (0)
>
> 'Set variables for application name and file name/path
> stAppName = "Excel.exe"
> strFileName = "c:\Downloads\Domestic_Samples.xls"
>
> 'Open Excel file through use of Shell command
> Call Shell(stAppName & " " & Chr(34) & strFileName &
>Chr(34), 1)
>
>It runs fine on my work PC and also another test PC. On
>two other PC's, it is returning a "File Not Found" error.
>I have not been able to recreate the error on any PC's I
>have available, so I am at a loss as to why this is
>occuring. If I can't fix this, I can't use it, so any
>help is greatly appreciated.
>
>BTW: This is in Access 97 on Windows NT boxes.
>
>Thanks
>Kevin Webb
>United Parcel Service


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
shell function Richard Microsoft Access 3 23rd Apr 2009 03:42 AM
Shell function =?Utf-8?B?QW5keQ==?= Microsoft Access VBA Modules 7 12th Mar 2006 07:40 PM
Shell function and error trap tmort Microsoft Excel Programming 0 3rd Aug 2005 02:10 AM
Shell Function in .NET Lenny Microsoft VB .NET 2 25th Jul 2003 10:05 PM
Shell Function in .NET Lenny Microsoft Dot NET Framework 2 25th Jul 2003 10:05 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:05 PM.