vba get activate window name

The solution for “vba get activate window name” can be found here. The following code will assist you in solving the problem.

Public Declare Function GetForegroundWindow Lib “user32” _
Alias “GetForegroundWindow” () As Long
Public Declare Function GetWindowText Lib “user32” _
Alias “GetWindowTextA” (ByVal hwnd As Long, _
ByVal lpString As String, ByVal cch As Long) As Long

Sub AAA()
Dim WinText As String
Dim HWnd As Long
Dim L As Long
HWnd = GetForegroundWindow()
WinText = String(255, vbNullChar)
L = GetWindowText(HWnd, WinText, 255)
WinText = Left(WinText, InStr(1, WinText, vbNullChar) – 1)
Debug.Print L, WinText
End Sub

Thank you for using DeclareCode; We hope you were able to resolve the issue.

More questions on [categories-list]

Similar Posts