Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / July 2007

Tip: Looking for answers? Try searching our database.

Track "WINWORD.EXE" VB

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
jCheah@iso.com - 22 Jul 2007 15:07 GMT
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..
Russ - 22 Jul 2007 23:12 GMT
For part of answer (1) see these message snippets:
>>>>>Quote
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.

Signature

Regards
Jonathan West - Word MVP

>>>>>UnQuote

>>>>>Quote
Here 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
'_______________________________________

Signature

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP

>>>>>>UnQuote

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.

> Hi everyone,
>
[quoted text clipped - 11 lines]
>
> Help PLEASEE... Thanks..

Signature

Russ

drsmN0SPAMikleAThotmailD0Tcom.INVALID

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.