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

Opening a word document from excel using VBA

Status
Not open for further replies.

rappoman

Computer
Joined
Jul 8, 2004
Messages
1
Location
US
Hi,

I'm pretty new to VBA, and I am trying to open a word document from excel VBA. Can anyone help?
 
some very ancient code, no guarantees about functionality:

Code:
    If Tasks.Exists("Microsoft Word") Then Set WordApp = GetObject(, "word.application")
    If WordApp = "" Then Set WordApp = CreateObject("word.application")

    WordApp.Documents.Open FileName:=DwellPath, ReadOnly:= _
        False, AddToRecentFiles:=False, PasswordDocument:="", PasswordTemplate:= _
        "", Revert:=False, WritePasswordDocument:="", WritePasswordTemplate:="", _
        Format:=wdOpenFormatAuto



TTFN
 
A big part of the answer depends on the level of interaction you want between the Excel and Word applications.

If all you want to do is open the Word document as a stand-alone application, then I would use the ShellExecute API using the name of the Word document.

On the other hand, if you want to open the document, and then manipulate the document from within the Excel application, then you will need to use the Word automation objects, as IRStuff has shown the beginnings of.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top