Controlling MS Word from Access 2007

L

LA Lawyer

I presume that this is a fairly common issue. Using Access 2007, I want to:

1. Determine if MS Word 2007 is running or not. If it is open, I want to
open a new document so that I can run some Word code. If Word is not open,
I want to open it and do my thing. I do NOT need the user to see this being
done, especially if it slows down the process.

2. Once I am done, I want to return Word to its prior state.

How is this done?
 
M

Mr. B

LA Lawyer,

In an extisting tread in the "Programming" newsgroup for Access, Dirk
Goldgar provided this answer to "How to tell if word is already running":

Dim oWord As Object

On Error Resume Next
Set oWord = GetObject(, "Word.Application")
If Err.Number = 0 Then
oWord.Activate
oWord.Quit
Set oWord = Nothing
End If

You can use the If part to do what you want to do when Word is already open,
whatever you need to do and add an "else" to the code above and use that
section to do what you need to do when Word is not running.
 

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