Hi Neil,
I got that hint just yersterday by Christian Freßdorf
of the German MVPs.
Private Declare Function FindWindow Lib "user32" Alias _
"FindWindowA" (ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long
Private Declare Function SetForegroundWindow Lib "user32" _
(ByVal hwnd As Long) As Long
Private Declare Function SetActiveWindow Lib "user32.dll" _
(ByVal hwnd As Long) As Long
Private Sub GetWordHandle()
Dim lHandle As Long
Dim retval As Long ' return value
' find window with the given document name
lHandle = FindWindow(vbNullString, ActiveDocument.Name & " - " _
& Application.Name)
'Set this window to the foreground
'lHandle = SetForegroundWindow(lHandle)
or
retval = SetActiveWindow(lHandle)
' set lHandle as the application's active window
'If the function succeeds,
'the return value is the handle to the window
'that was previously active.
'If the function fails, the return value is NULL.
'To get extended error information, call GetLastError.
Debug.Print retval ' !!!
End Sub
Greetings from Bavaria, Germany
Helmut Weber
"red.sys" & chr(64) & "t-online.de"
Word XP, Win 2000