VB Code:
'in a module
Public Declare Function IsWindowVisible Lib "user32" (ByVal hwnd As Long) As Long
Public Declare Function EnumWindows Lib "user32" (ByVal lpEnumFunc As Long, ByVal lParam As Long) As Long
Public Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Public Const MAX_LEN = 260
Public Function EnumWinProc(ByVal hwnd As Long, ByVal lParam As Long) As Long
Dim lRet As Long
Dim strBuffer As String
If IsWindowVisible(hwnd) Then
strBuffer = Space(MAX_LEN)
lRet = GetWindowText(hwnd, strBuffer, Len(strBuffer))
If lRet Then
Form1.List1.AddItem Left(strBuffer & " " & hwnd, lRet)
End If
End If
EnumWinProc = 1
End Function
'on a form with a listbox and command button
Private Sub cmdListProcesses_Click()
Call EnumWindows(AddressOf EnumWinProc, 0)
End Sub
I've never done any development in Excel, so I don't know if this will work on that platform, but it works just fine using VB. :)