checking for an instance of Word

T

Ted

Hi all,

I'm running some VBA code thru Access to open Word and print some documents.
How do I check to see if an instance of Word is already running?

Thanks in advance
Ted
 
J

Jezebel

Dim pWordApp as Word.Application (or as Object)

'Retrieve existing instance if any
on error resume next
Set pWordApp = GetObject("Word.Application")
On error goto 0

'Failing that, create a new instance
If pWordApp is nothing then
set pWordApp = CreateObject("Word.Application")
End if
 

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