Using an Excel macro to open a Word File
If you want to control the word document, createobject seems better.
If you just want to open the document, you could use shell or even
followhyperlink().
ActiveWorkbook.FollowHyperlink Address:="c:\path\name.doc"
An example saved from a previous post:
Option Explicit
Sub Testme()
Dim WDApp As Object
Dim WDDoc As Object
Dim myDocName As String
myDocName = "s:\lost property master sheets\sheet3.doc"
Set WDApp = CreateObject("Word.Application")
WDApp.Visible = True 'at least for testing!
Set WDDoc = WDApp.documents.Open(Filename:=myDocName)
WDDoc.PrintOut '.printPreview while testing???
WDDoc.Close savechanges:=False
WDApp.Quit
Set WDDoc = Nothing
Set WDApp = Nothing
End Sub
lhyer wrote:
Can someone please help me with an example of what the code would look like
to open a Word file from a macro in Excel? Is it better to use the shell or
the createobject function?
--
Dave Peterson
|