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

How do I open a specific word document from within and excel macro?

Status
Not open for further replies.

jackiec

IS-IT--Management
Joined
Feb 20, 2003
Messages
1
Location
GB
I have written a macro in excel which transfers data from our main computer to the user's pc. I now require the macro to open a specific document, in word, which also contains a macro which performs a mail merge and prints the resulting document(s) out.

The following code, when inserted in the excel macro, opens word with a blank document1:-

Application.ActivateMicrosoftApp xlMicrosoftWord

I have also found the following code:-

l_appWord.Document.Open("filname.doc")

which is supposed to open the specific document, but, I can't get the sysntax right in my macro.
 
Try this code

Sub Test()

Dim appWrd As Word.Application, strFileLoc as string

Set appWrd = CreateObject("Word.Application")
strFile = "c:\Directory\of\file\FileName.doc"

appWrd.Documents.Open strFile
appWrd.Visible = True

End Sub


Hope it helps!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top