Opening file with VBA command

  • Thread starter Thread starter roadie.girl
  • Start date Start date
R

roadie.girl

Hi All -

I have a switchboard and I'm trying to open a file when my user clicks
on a button. Problem is that there are spaces in the file name (I can't
change this - it's just how it is). So i was wondering how to do this
....

Right now I have

openDW = ShellExecute(MSAccess.exe F:\JQ\Utilities\Just
Quarterly\Database Application Program.mde, 1)

which throws an error.

thanks in advance for any help!!!
 
What is ShellExecute? If you're trying to use the ShellExecute API, you
don't need to pass the executable to it: that's the whole point of the API
call. The VBA command is simply Shell. Have you got some custom function in
your application that you're using?

If this were Shell, you'd use

openDW = Shell("MSAccess.exe ""F:\JQ\Utilities\Just Quarterly\Database
Application Program.mde""", 1)
 
Hi All -

I have a switchboard and I'm trying to open a file when my user clicks
on a button. Problem is that there are spaces in the file name (I
can't change this - it's just how it is). So i was wondering how to
do this ...

Right now I have

openDW = ShellExecute(MSAccess.exe F:\JQ\Utilities\Just
Quarterly\Database Application Program.mde, 1)

which throws an error.

thanks in advance for any help!!!

Try this:

openDW = ShellExecute( _
"MSAccess.exe " & _
Chr(32) & _
"F:\JQ\Utilities\Just Quarterly\" & _
"Database Application Program.mde" & _
Chr(32), _
1)

That should get quotes around the filename into the string passed to
ShellExecute.
 
Thank you so much, Doug!! That worked great. It was the extra " mark
that I was missing that fixed the entire thing. (And yes, the
ShellExecute was just a typo on my part ... i was just trying to run
the Shell() function)
 
Dirk Goldgar said:
Try this:

openDW = ShellExecute( _
"MSAccess.exe " & _
Chr(32) & _
"F:\JQ\Utilities\Just Quarterly\" & _
"Database Application Program.mde" & _
Chr(32), _
1)

That should get quotes around the filename into the string passed to
ShellExecute.

And of course Doug was right about using Shell vs. ShellExecute.
 

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

Back
Top