Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • 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
Jul 8, 2004
1
Hi,

I'm pretty new to VBA, and I am trying to open a word document from excel VBA. Can anyone help?
 
Replies continue below

Recommended for you

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