Error with Shell Function

K

Kevin Webb

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
 
T

TC

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
 
H

Heiko

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
:)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top