! Launch MSWord !

W

Wembly

Hi,

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

How does one do this?

Thanks.

Wembly
 
G

Glenn

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
 
N

Naresh Nichani MVP

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top