This works:
strCommand = "winword.exe C:\test.doc /mDoThis"
varMyDoc = Shell(strCommand, vbMaximizedFocus)
When I execute this, I get a file not found error:
strCommand = "winword.exe C:\Documents and Settings\mbartley\test.doc"
varMyDoc = Shell(strCommand, vbMaximizedFocus)
Same thing for this:
strCommand = "winword.exe 'C:\Documents and
Settings\mbartley\test.doc'"
varMyDoc = Shell(strCommand, vbMaximizedFocus)
My assumption is it's the spaces in the directory that are flummoxing the
compiler.
I'm modifying someone else's complicated code. This is a utility procedure,
and I don't want to change the overall logic by implementing a different
approach, I want to keep the Shell command logic, but don't know how to
implement it when I've got a space in the file name.
Any help?
Jay Freedman - 23 Nov 2005 05:15 GMT
>This works:
> strCommand = "winword.exe C:\test.doc /mDoThis"
[quoted text clipped - 18 lines]
>
>Any help?
You need to embed double quotes in the string to surround the path:
Dim qt As String
qt = Chr$(34)
strCommand = "winword.exe " & qt & _
"C:\Documents and Settings\mbartley\test.doc" & qt
--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.
Thomas Lindberg - 23 Nov 2005 06:11 GMT
>>This works:
>> strCommand = "winword.exe C:\test.doc /mDoThis"
[quoted text clipped - 33 lines]
> Email cannot be acknowledged; please post all follow-ups to the
> newsgroup so all may benefit.
The need for double quotes in macros pops up now and then but I have not yet
found a so simple way to realize it!
Thanks, Jay!
Thomas