View Single Post
  #8  
Old February 8th 05, 11:15 AM
Jonathan West
external usenet poster
 
Posts: n/a
Default

If you want to get hold of an existing instance of Word, then you should use
GetObject as Jezebel described to get an object reference to it. Then you
can use the Run method of the Word Application object to run the macro.

--
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup

"Larry" wrote in message
...


Thanks Jezebel.

Since it is possible from the Run dialog box to start Word and run a
macro in one step, I'm thinking that if, with Word open but not active,
I ran the macro I'm looking for, I could get a macro that activated the
open Word window without opening a second instance of Word.

However, when I create a macro in Normal called WordActivate using the
code you suggested,

Dim wrdApp as object
On error resume next
Set wrdApp = GetObject("Word.Application")

and (with Word open but not active) run this in the Run dialog box:

Winword.exe /mWordActivate

A second instance of Word opens.

The same happens when I put the other set of code in WordActivate.

Any other ideas? Thanks much.

Larry




Jezebel wrote:
If you mean from VB, there are two methods --

1) Late binding

Dim wrdApp as object
On error resume next
Set wrdApp = GetObject("Word.Application")
If wrdApp is nothing then
.... Word was not running .... no instance to get


or 2) Early binding

Dim wrdApp as Word.Application
On error resume next
Set wrdApp = Word.Application
If wrdApp is nothing then
.... Word was not running .... no instance to get




"Larry" wrote in message
...
I would be great to find a way to activate Word without starting a
new Word instance. I think I asked about this a year or two ago,
and didn't get anywhere. Any ideas?