|
-
March 6th, 2007, 06:30 AM
#1
Identifying PID of
I use word automation and open a new word instance which opens a given document.
Like that:
Dim oDoc As Word.Document
Dim oWord As New Word.Application
oWord.Visible = False
oDoc = oWord.Documents.Open(srcName)
I need to identify the PID (process ID) of the newly created word instance.
It seems that it isn't a son process of the process which called it.
How can I find its PID?
-
March 6th, 2007, 09:39 AM
#2
Re: Identifying PID of
If the post was helpful...Rate it! Remember to use [code] or [php] tags.
-
March 6th, 2007, 10:12 AM
#3
-
March 6th, 2007, 11:15 AM
#4
Re: Identifying PID of
I dint think that would work because the new word instance is invisible hence GetWindowThreadProcessId wouldn't work?
Is there any general rule on the PID of the word instance or the its relation with the calling process?
-
March 6th, 2007, 11:27 AM
#5
Re: Identifying PID of
How does a window being invisible keep you from getting the HWND?
If the post was helpful...Rate it! Remember to use [code] or [php] tags.
-
March 6th, 2007, 11:59 AM
#6
Re: Identifying PID of
something like this perhaps:
Code:
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" ( _
ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function GetWindowThreadProcessId Lib "user32" ( _
ByVal hwnd As Long, lpdwProcessId As Long) As Long
Private Sub Command1_Click()
Dim oWord As Word.Application
Dim pID As Long
Set oWord = New Word.Application
GetWindowThreadProcessId FindWindow(vbNullString, oWord.Caption), pID
Debug.Print pID
oWord.Quit
Set oWord = Nothing
End Sub
-
March 6th, 2007, 01:29 PM
#7
Re: Identifying PID of
This doesn't seem to work, I get pID = 0.
-
March 6th, 2007, 01:31 PM
#8
Re: Identifying PID of
strange, I get a value
-
March 6th, 2007, 01:48 PM
#9
Re: Identifying PID of
Can you send me your source code, it would really help
[email protected]
-
March 6th, 2007, 02:24 PM
#10
Re: Identifying PID of
 Originally Posted by tepez
Can you send me your source code, it would really help
He already posted the source code.
If the post was helpful...Rate it! Remember to use [code] or [php] tags.
-
March 6th, 2007, 02:57 PM
#11
Re: Identifying PID of
I know, I ment the entire source, maybe there is something I did wrong...
-
March 6th, 2007, 03:12 PM
#12
Re: Identifying PID of
Try making it visible to see if it's loading, and getting the right filename.
That code should work, if Word is open. Look in Task Manager.
-
March 6th, 2007, 03:41 PM
#13
Re: Identifying PID of
 Originally Posted by tepez
I know, I ment the entire source, maybe there is something I did wrong...
He did post the entire source. It was an example code for you to follow. Do as dglienna suggested. Task manager can also list the PID column.
If the post was helpful...Rate it! Remember to use [code] or [php] tags.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|