'Benötigte
API-Funktion deklarieren:
Public Declare Function mlfpApiFindWindow Lib "user32" _
Alias "FindWindowA" (ByVal lpClassName As Any, _
ByVal lpWindowName As String) As Long
'Funktion, um das Hanlde der aktuellen Instanz zu erlangen
Function GetHandle() As Long
If InStr(Left(Application.Version, 2), ".") > 0 Then
GetHandle = GetOldHandle
Else
GetHandle = self.hwnd
End If
End Function
'Hilfs-Funktion, um das Hanlde der aktuellen Instanz bei älteren Office-Versionen zu erlangen
Function GetOldHandle() As Long
Dim OldCap As String
OldCap = Application.Caption
Application.Caption = "ABCDEFGHIJKLMNOP"
GetOldHandle = mlfpApiFindWindow("XLMAIN", Application.Caption)
Application.Caption = OldCap
End Function
'Testaufruf
Sub Test
MsgBox GetHandle
End Sub