Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / August 2006

Tip: Looking for answers? Try searching our database.

Shelling Wordpad

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
DavidJ - 24 Aug 2006 12:42 GMT
Hi all

Wonder if anyone can help...

I am shelling wordpad in vba code but wordpad doesn't seem to like
spaces in the filename.

My code...

Private Sub cmdNotepad_Click()

   Dim varX As Variant
   Dim strMyDoc As String

   strMyDoc = "C:\Documents and Settings\Doc\My Documents\Nis2.rtf"
   'strMyDoc = "C:\setup.log"

   varX = Shell("C:\Program Files\Windows NT\Accessories\wordpad.exe"
& " " & strMyDoc, vbMaximizedFocus)

End Sub

When run with setup.log it works fine but when using Nis2.rtf wordpad
complains it can't find the file, and show the filename up to the first
space in "Document and Settings"

Any suggestions would be appreciated
Graham Mayor - 24 Aug 2006 13:54 GMT
Change strMyDoc to

strMyDoc = """C:\Documents and Settings\Doc\My Documents\Nis2.rtf"""

Signature

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor -  Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>

> Hi all
>
[quoted text clipped - 23 lines]
>
> Any suggestions would be appreciated
Roger Hunt - 24 Aug 2006 14:35 GMT
>Hi all
>
[quoted text clipped - 23 lines]
>
>Any suggestions would be appreciated

Shot in the dark - perhaps Wordpad uses the MSDOS path name, internally.
So I wonder if this would work  :
       strMyDoc = "C:\Docume~1\doc\Mydocu~1\Nis2.rtf"
Signature

Roger Hunt

DavidJ - 25 Aug 2006 11:00 GMT
> >Hi all
> >
[quoted text clipped - 29 lines]
> --
> Roger Hunt

Spot on Roger, while both solutions worked as hard coded path/filename
when obtained from forms using the MSGOS path name worked perfectly.

Thanks for the assistance guys.
DavidJ - 25 Aug 2006 11:02 GMT
> > >Hi all
> > >
[quoted text clipped - 34 lines]
>
> Thanks for the assistance guys.

Whoops, typo, I did mean MSDOS of course.
Roger Hunt - 25 Aug 2006 16:14 GMT
>> >Hi all
>> >
[quoted text clipped - 30 lines]
>Spot on Roger, while both solutions worked as hard coded path/filename
>when obtained from forms using the MSGOS path name worked perfectly.

Nice one! But I think Graham's solution is better practise - I was
always taught (our VB tutor beat it into us with a thick manual) that
the clearer the code, if possible, the better, and sprinkled with
appropriate comments.

Cheers
Signature

Roger Hunt

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.