Launch Word.Doc using eg.Code

wazza

Registered User.
Local time
Today, 12:28
Joined
Apr 23, 2004
Messages
104
Hi

I have been using the following code to open an Excel file. I wish to open a Word document - can i siply adjust this code? Ive tried but no luck...

rgrds


Set oapp = CreateObject("Excel.Application")
oapp.visible = true
Set wb = oapp.Workbooks.Open("C:\imports\testfile.xls")
set ws = wb.activesheet
 
try...

Code:
Call Shell("C:\Program Files\Microsoft Office\Office\Word.exe C:\imports\testfile.doc", vbMinimizedFocus)

or

Code:
Application.FollowHyperlink "C:\imports\testfile.doc"
 
Or

Code:
Sub lateBinding()
   Dim oapp As Object
    Set oapp = CreateObject("Word.Application")
    oapp.Documents.Open ("c:\myfile.doc")
    oapp.Visible = True
    oapp.Quit
    set oapp = nothing
End Sub

OR

Code:
Sub earlyBinding()
    'BUT FIRST.... Set a reference to the Microsoft Word Object Library
    Dim wrd As Word.Application
    Set wrd = New Word.Application
    wrd.Documents.Open ("c:\myfile.doc")
    wrd.Visible = True
    wrd.Quit
    set wrd = nothing
End Sub
 
Last edited:

Users who are viewing this thread

Back
Top Bottom