modeless userform

  • Thread starter Thread starter jacob
  • Start date Start date
J

jacob

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
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top