This sub returns the caption of the userform, or of Excel, depending on
which is the active window:
Declare Function GetActiveWindow32 Lib "user32" Alias _
"GetActiveWindow" () As Integer
Public Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" _
(ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Private Const BUFFER_LEN As Long = 254
Sub ShowActiveWindow()
Dim RetLen As Long
Dim sBuffer As String * BUFFER_LEN
RetLen = GetWindowText(GetActiveWindow32, sBuffer, BUFFER_LEN)
If RetLen > 0 Then MsgBox Left(sBuffer, RetLen)
End Sub
--
Jim Rech
Excel MVP
| Hi,
| With a modeless userform, is it possible to detect its
| state via VBA, i.e. if it has focus or not?
|
| What is client coordinates?
|
| Any help appreciated.
|
| jacob