View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming,microsoft.public.word.vba.general
Ed Ed is offline
external usenet poster
 
Posts: 399
Default Check if Word is already active?

I pulled up an Excel macro I wrote in my absolute newbie days (not that I'm
too much farther down the road!) that opens a Word doc. It still works, but
now I can see that it needs some tweaking. I use
Dim WD As Object
doc = Fpath & "\" & Fname & ".doc"
Set WD = CreateObject("Word.Application")
WD.Documents.Open doc
WD.Visible = True
Set WD = Nothing
(doc, Fpath, and Fname are all declared as well.)
Besides being late binding, this opens an entirely new instance of Word,
which can do some strange things to me, depending on what I'm doing in Word
at the moment. What I'd really like to do is check to see if Word is
running first; if it is, then open the new doc within the current instance -
if not, then open a new instance. What's the best way to check if Word is
already running?

Ed