AW: ProcessID zuweisen
18.10.2006 14:27:22
Heiko
Hallo Ingo,
Frage die Info doch direkt ab, nach Start von Outlook durch .ActivateMicrosoftApp.
Option Explicit
Private Declare Function GetWindowThreadProcessId Lib _
"user32" (ByVal hwnd As Long, lpdwProcessId As Long) As Long
Private Declare Function FindWindow Lib "user32" _
Alias "FindWindowA" ( _
ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long
Private Function GetWindowTaskID(strWinName As String) As Long
' Ermittelt die TaskID eines Windows anhand des WindowName
Dim lResult As Long, lTemp As Long, hwnd As Long
hwnd = FindWindow(strWinName, vbNullString)
lResult = GetWindowThreadProcessId(hwnd, lTemp)
GetWindowTaskID = lTemp
End Function
Sub test()
' rctrl_renwnd32 = Outlook Windows Name
' XLMAIN wäre der für EXCEL, OpusApp der für Word ...
MsgBox GetWindowTaskID("rctrl_renwnd32")
End Sub
Gruß Heiko
PS: Rückmeldung wäre nett !