! Launch MSWord !

  • Thread starter Thread starter Wembly
  • Start date Start date
W

Wembly

Hi,

I was wondering if it was possible to launch MSWord from
Access via code?

How does one do this?

Thanks.

Wembly
 
This is the basic code to create an instance of Word using
Office 2000.........

Sub automateWord()

Dim wordApp As Word.Application

' Create new hidden instance of Word.
Set wordApp = New Word.Application
' Show this instance of Word.
wordApp.Visible = True

With wordApp
' Code to automate Word here.
End With

wordApp.Quit
Set wordApp = Nothing
End Sub


Rgds,
Glenn
 
Hi:

Here is another way to do this (this does not need a Word reference and also
checks if a Word instance is running already).

Dim objWord as Object

On Error Resume Next 'ignore error here as Word may not be running
Set objWord = GetObject(,"Word.Application") 'check for running instance of
Word
If objWord is Nothing then
Set objWord = CreateObject("Word.Application")
if objWord is Nothing then
Msgbox "Cannot start Word"
Exit sub
end if
end if

On error goto errHandler 'this is your custom Error Handler
With objWord
.Visible = True
'do other stuff as needed
End With

Regards,

Naresh Nichani
Microsoft Access MVP
 
Back
Top