Private Declare Function GetWindowTextLength Lib "user32.dll" Alias "GetWindowTextLengthA" (ByVal hwnd As Long) As Long
Private Declare Function GetWindowText Lib "user32.dll" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal nMaxCount As Long) As Long
Private Declare Function EnumWindows Lib "user32.dll" (ByVal lpEnumFunc As Long, ByVal lParam As Long) As Long
Private Declare Function IsWindowVisible Lib "user32" (ByVal hwnd As Long) As Long
Private x&
Private Function EnumWindowsProc&(ByVal hwnd&, ByVal lParam&)
Dim SLength&, Buffer As String, RetVal&
SLength = GetWindowTextLength(hwnd) + 1
If SLength > 1 Then
Buffer = Space(SLength)
RetVal = GetWindowText(hwnd, Buffer, SLength)
x = x + 1
Cells(x, 1) = Left(Buffer, SLength - 1)
Cells(x, 2) = CBool(IsWindowVisible(hwnd))
End If
EnumWindowsProc = 1
End Function
Sub WinList()
Application.ScreenUpdating = False
Cells.ClearContents
Cells(1, 1) = "CAPTION"
Cells(1, 2) = "VISIBLE"
Range("A1:B1").Font.Bold = True
Range("A2").Select
ActiveWindow.FreezePanes = True
x = 1
EnumWindows AddressOf EnumWindowsProc, 0
Cells.Columns.AutoFit
End Sub