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 John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

opening a word file from VBA in Excel 1

Status
Not open for further replies.
Jul 18, 2006
9
GB
I am trying to open a word file from a command button in excel. I've been trying to use:

Code:
filenam = "\filename.doc"
loc = activeworkbook.path
helpfil = loc & filenam

RetVal = Shell("C:\Program files\Microsoft Office\Winword.exe " & helpfil, vb normal focus)

However, this does not work. It opens word, and then an error box saying:

Word experienced an error trying to open the file. Try the following:
- check the file permissions for the document or drive
- make sure there is sufficient free memory and disc space
- open the file with Text Recovery converter.

I do not understand what this means - does anybody know what could be wrong? Or does anybody know another way to open a word file from excel?

Thanks

hwc535
 
You may try to replace this:
helpfil = loc & filenam
with this:
helpfil = chr(34) & loc & filenam & Chr(34)

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Or, instead of using Shell, make an instance of Word...and just open the file. Shell is going to make an instance of Word anyway, so why not just make Word?

Gerry
My paintings and sculpture
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top