Hello,
I'm having trouble with the Shell command from VBA.
This line of code works:
But when I replace the hard coded paths with the variables, as below, it does not work and tells me "C:\Documents cannot be found" because I am not passing in any " around the parameters.RetVal = Shell("""C:\Program Files\eQUEST 3-64\eQuest.exe"" ""C:\Documents and Settings\All Users\Documents\eQUEST 3-64 Projects\Large Office Case Study 6\BatchData.eQBatch""", vbMaximizedFocus)
How do I pass in quotes around the path and parameter, as I'm doing in the example above???RetVal = Shell(ProgFolder & "\eQuest.exe " & ProjFolder & "\BatchData.eQBatch", vbMaximizedFocus)
Thanks!
BRL
Last edited by brl8; 09-30-2010 at 12:05 PM.
These quote problems are stumpers and I've spent lots of time building them incorrectly.
I've found that building a String Variable first, with all the correct values and then placing this in the call normally works.
My second hint on putting quotes in these calls is to defind a Constant called QUOTE = Chr(34) and use & QUOTE & in building your strings.
Double them as in your original:
RetVal = Shell("""" & ProgFolder & "\eQuest.exe"" """ & ProjFolder & "\BatchData.eQBatch""", vbMaximizedFocus)
This is the way I do it:
RetVal = Shell(replace("#" & ProgFolder & "\eQuest.exe# #" & ProjFolder & "\BatchData.eQBatch#","#",chr(34)), vbMaximizedFocus)
Awesome! Thanks all for the great suggestions.
Here's what it took:
Thanks All.Quote = Chr(34) ShellStr = Quote & ProgFolder & "\eQuest.exe" & Quote & " " & Quote & ProjFolder & "\BatchData.eQBatch" & Quote RetVal = Shell(ShellStr, vbMaximizedFocus)
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks