
Problem using Shell Function with MS Wordpad
Try it like this:
Private Sub test()
Dim strEditor As String
Dim strFile As String
strEditor = "c:\Program Files\Accessories\Wordpad.exe"
strFile = "c:\My Documents\New Text Document.txt"
Shell strEditor & " " & Chr$(34) & strFile & Chr$(34),
1
End Sub
The Chr$(34) generates a double-quote on the fly.
Quote:
>-----Original Message-----
>Hi!
>I recently got some help on this board in using the Shell
>command to run MS Wordpad from VBA code. I have a
problem
>though when I'm using a command line like the following:
>Shell editor file, 1
>where...
>editor = "c:\Program Files\Accessories\Wordpad.exe"
>file = "d:\My Documents\test.txt"
>It doesn't seem to work as long as there are spaces at
all
>in the target file name (i.e. between y and D). It works
>fine if I take out the space. Is there any way to get
>around this?
>Any help would be greatly appreciated.
>Thanks!
>Dan A.
>.