Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Shell to Winword from extra basic

Status
Not open for further replies.

santlou

Programmer
Jan 29, 2003
6
0
0
US
Hi,

I have a macro that creates a txt file.

I want to bring this file up using Word automatically after the file is created. I tried to shell to word, but I cant specify the document name in the shell statement.

myfile = "this is my file.txt"
Shell("Winword " + myfile)

this causes an error because the name of the file needs to be enclosed in quotes. I've tried several methods to invoke this call.. but all fail.

Can anybody help ?

I know that the proper way is to use OLE to get into word, but I figured the shell method is a quick and dirty solution... if i can get it to work.

thanx... Lou
 
I tried your script without declaring a variable for the name of myfile, and it worked fine. Something like:

Code:
Shell("Winword","C:\bootlog.txt")

HTH
 
You may also use the following:

myfile = "this is my file.txt"
Shell("Winword " + chr$(34) + myfile + chr$(34))

where chr$(34) is the quote you need

 
While I've never used the Chr(34) option, I've been unable to fire a macro with spaces in the name. No matter what workaround I tried, the only thing that worked was to get the spaces out.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top