Call Shell with a space in the command line argument

R

rubyt

I am launching Access using the Shell function and passing
an argument which is the path and filename of the .mdb
file to run. The path to the .mdb file is
C:\Documents and Settings\ruby\my.mdb and no matter what I
do to pass this path (which has a space in the path name
after "Documents"), the Shell function always sees the
space and won't run. I've tried concatenating strings,
but Shell doesn't like single quotes either around the
argument.

dim strX as string

strX = "c:\program files\microsoft
office\office\msaccess.exe c:\Documents and
Settings\ruby\my.MDB"

call shell(strX,1)

It comes back with a message that it can't find
c:\Documents.mdb.

Anyone know what to do?
 
D

Douglas J. Steele

Try

strX = """c:\program files\microsoft office\office\msaccess.exe""
""c:\Documents and Settings\ruby\my.MDB"""

That's 3 double quotes at the beginning, two double quotes, a space and two
more double quotes in the middle, and 3 double quotes at the end.
 
G

Guest

I failed to mention that I am trying to pass a string
variable as the command line argument and not hard code
the location since it will be different for different
users, i.e.

strY = "c:\Documents and Settings\ruby\my.mdb"

What you sent me does work but I need to use a variable.
The msaccess.exe part is hard coded. Can you help one
more time?

Thank you.
Ruby
 
R

rubyt

I tried and tried and finally got it so ignore my previous
message. Thanks for your help!

Ruby
 

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