Track "WINWORD.EXE" VB

J

jCheah

Hi everyone,

I have a case where there will be multiple "WINWORD.EXE" instances
running at the same time in Task Manager. Each "WINWORD.EXE' might be
controlling one Word document or a few Word documents or even none.

(1) My question is, is there anyway to track like which "WINWORD.EXE"
is controlling which Word Document(s). I want to do it programatically
in VB.

(2) And also, is there anyway to track any hanging "WINWORD.EXE"? As i
can see sometime "WINWORD.EXE" is not close even though you close the
word document. I want to do it programatically in VB.

Help PLEASEE... Thanks..
 
R

Russ

For part of answer (1) see these message snippets:If you want the user to continue working on other documents, you must
religiously avoid using any of the following

Selection
ActiveDocument
ActiveWindow

To avoid using the ActiveDocument object, always open a document using
syntax like this

Dim oDoc as Document
Set oDoc = Documents.Add(Filename:="my filename here")

That gives you a handle to the document you want to work on. Once you have
set oDoc, you can use it exactly as you would use ActiveDocument.

To avoid using the Selection object, always define a Range object from
within the specified document object. You can do almost anything with a
Range that you can do with the Selection, and you can have as many of them
as you want (whereas there is only one Selection)

To avoid using ActiveWindow, define a Window object based on oDoc in the
same way.


--
Regards
Jonathan West - Word MVPHere is a little something to get you going.
This assumes that Word is running. It would not be wise to assume that. See
the VBA help on GetObject/CreateObject for example of error trapping on
this. Of course, if you find that Word is not running, then it is a safe bet
that the document you want is not opened, much of the code below can then be
skipped...

'_______________________________________
Dim appWord As Word.Application
Dim docTarget As Word.Document
Dim i As Long

Const strDocName As String = "Document5"
Set appWord = GetObject(, "Word.Application")

With appWord
For i = 1 To .Documents.Count
If .Documents(i).Name = strDocName Then
Set docTarget = .Documents(i)
Exit For
End If
Next
End With

If docTarget Is Nothing Then
MsgBox "The target document is not opened."
Exit Sub
End If

With docTarget
'Manipulate doc here, example:
.Paragraphs(2).Range.Font.Bold = True
End With
'_______________________________________

--

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
Also look up the Task object in Word VBA help.

Part of answer (2) is that if another Office app (Outlook?) is using
spellchecking then a winword.exe will be open in the task pane.
 

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