Problem using Shell Function with MS Wordpad 
Author Message
 Problem using Shell Function with MS Wordpad

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.



Fri, 02 Apr 2004 23:24:04 GMT  
 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.
>.



Fri, 02 Apr 2004 23:51:10 GMT  
 Problem using Shell Function with MS Wordpad
Thanks John!

It worked great.

Have a great day!

Dan

Quote:
>-----Original Message-----
>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.

>>-----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.
>>.

>.



Sat, 03 Apr 2004 00:38:47 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Problem executing DOS command using Shell function

2. problem using shell function

3. I have problem using function "Shell"

4. Shell to Wordpad

5. FULL SCREEN MS-DOS using SHELL

6. Browsing for Printers using SHBrowseForFolder Shell Function

7. Using Shell function

8. Using variable command with Shell function

9. Using the Shell Function

10. Using Shell Function

11. Using Shell Function of VB.Net in a Web Form

12. Using Shell Function of VB.Net in a Web Form

 

 
Powered by phpBB® Forum Software