Dim a As Long on error resume next a = Me.ActiveControl.hWnd
Option Explicit Private Declare Function GetFocus Lib "user32" () As Long Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As LongPrivate Sub Timer1_Timer() On Error Resume Next Dim s As String * 50 Dim hwnd As Long, l As Long hwnd = GetFocus l = GetWindowText(hwnd, s, 50) Debug.Print Left$(s, l) End Sub
Dim a As Long
on error resume next
a = Me.ActiveControl.hWnd
Private Declare Function GetFocus Lib "user32" () As Long
Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As LongPrivate Sub Timer1_Timer()
On Error Resume Next
Dim s As String * 50
Dim hwnd As Long, l As Long
hwnd = GetFocus
l = GetWindowText(hwnd, s, 50)
Debug.Print Left$(s, l)
End Sub