What Mike is after is the windows handle for
the activewindow which I'm picking is the active
windows handle for excel....if so then this will
get the handle to the activewindow;
Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Sub GetActiveXl_Hwnd()
Dim xlAppCaption As String
Dim hWndXl As Long
xlAppCaption = "Microsoft Excel - " & ActiveWindow.Caption
hWndXl = FindWindow("XLMAIN", xlAppCaption) '
MsgBox "The Activewindow:= " & xlAppCaption & " ) has the Window Handle " & _
vbCrLf & "Hex:=" & Hex(hWndXl) & vbCrLf & _
"Dec:=" & hWndXl & vbCr & vbCrLf & _
"You can use this Window Handle in various Win 32 APIs, " & vbCrLf & _
"such as SetForeGroundWindow," & vbCr & _
"which require a Window Handle parameter to be supplied." & vbCr _
& vbCrLf, vbMsgBoxSetForeground
End Sub
HTH
Ivan What do you mean?
Thanks Ivan. That's sort of what I was looking for. I knew I could get it through the WIN32 API. I was just wondering if VBA revealed the window handles like VB does, as a property.
But this will work. Thanks again.
-Mike the activewindow which I'm picking is the active windows handle for excel....if so then this will get the handle to the activewindow; (ByVal lpClassName As String, ByVal lpWindowName As String) As Long Dim xlAppCaption As String Dim hWndXl As Long vbCrLf & "Hex:=" & Hex(hWndXl) & vbCrLf & _ "Dec:=" & hWndXl & vbCr & vbCrLf & _ "You can use this Window Handle in various Win 32 APIs, " & vbCrLf & _ "such as SetForeGroundWindow," & vbCr & _ "which require a Window Handle parameter to be supplied." & vbCr _ & vbCrLf, vbMsgBoxSetForeground End Sub
HTH Ivan : : What do you mean? : Jacob