Shell function w/Parameters

teel73

Registered User.
Local time
Today, 04:56
Joined
Jun 26, 2007
Messages
205
I'm trying to open another Access database with wrkgroup parameters using the Shell function. I get a "file not found" error when trying to run the function. Here's what I have:

Code:
Dim varSitewide As Variant
Dim curUsr As String
curUsr = CurrentUser()
Const q As String * 1 = """"
MsgBox "Opening SEAMS..."
   
varSitewide = "C:\Program Files\Office 2003\OFFICE11\MSACCESS.EXE" & "C:\Documents and Settings\e3utbl\Desktop\Devl Databases\SCC_Dashboard\CSS_APPS\SEAMS\SEAMS.mdb" & " /wrkgrp" & "C:\Documents and Settings\e3utbl\Desktop\Devl Databases\SCC_Dashboard\CSSGrp.mdw" & " /user " & curUsr
 
RetVal = Shell(varSitewide, 1)

I can paste the above string in the target location of a desktop shortcut and it opens just fine. I'm sure it has something to do with the spaces but it seems I tried everything but I can't get it to work. Any help out there?

Thanks in advance.
 
the first thing I personally see, teel, is that the file not found error is most likely cause becaue there is no space between the execution parameter and file parameter in your command. the computer will read what you've got as:
Code:
C:\Program Files\Office 2003\OFFICE11\MSACCESS.EXEC:\Documents and Settings\, etc...
change your ampersand sign to:
Code:
& " " &

furthermore, if you like doing shell, or even dos commands, it's a great practice to enclose all of the strings that are commands in double quotes. the command line in windows it doesn't matter, as it's read just fine, but DOS cannot interpret spaces correctly. in DOS, a file path with a space in it will error with no quotes surround it.
 

Users who are viewing this thread

Back
Top Bottom