1
votes

I'm able to use VBScript to start an instance of Word, give it some commands, and terminate:

Dim WordApp
Set WordApp = CreateObject("Word.application")
WordApp.DoSomething
WordApp.DoSomethingElse
WordApp.Quit

But if I have a running instance of word, can I connect to it using VBScript without starting up a new process?

1

1 Answers

4
votes

Use GetObject() instead of CreateObject(). Pass the ProgId ("Word.Application") as the 2nd parameter.

Dim WordApp
Set WordApp = GetObject(, "Word.Application")