Private Declare Function GetWindowText Lib "user32" Alias _
"GetWindowTextA" (ByVal hWnd As Long, ByVal lpString As String, _
ByVal cch As Long) As Long
Private Function GetWindowName(ByVal hWindow As Long) As String
Dim strTitle As String * 80
Dim lngLength As Long
lngLength = GetWindowText(hWindow, strTitle, Len(strTitle))
If lngLength Then
GetWindowName = strTitle
Else
GetWindowName = ""
End If
End Function