I found this at
I modified it to output to a message box. The piece I was missing was that you can leave the class empty and it will find it based on the Window title.
From
Option Explicit
'How can I activate an application with the Windows Classname?
'The VB AppActivate statement falls hopelessly short of being truly
'useful since the window title of an application can change without
'notice. A much more reliable means of activating another application
'is by using the window class name. It's much more reliable because
'the class name of a window will not change once the application has
'been installed. So, you ask, how do I get the class name of another
'application? You can find the window class name for any application
'by running a few lines of code. This is a one-time-only procedure.
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function GetClassName Lib "user32" Alias _
"GetClassNameA" (ByVal hwnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long
Private Declare Function ShowWindow Lib "user32" _
(ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
Const SW_SHOWNORMAL = 1
Const gcClassnameMSWord = "OpusApp"
Const gcClassnameMSExcel = "XLMAIN"
Const gcClassnameMSIExplorer = "IEFrame"
Const gcClassnameMSVBasic = "wndclass_desked_gsk"
Const gcClassnameNotePad = "Notepad"
Const gcClassnameMyVBApp = "ThunderForm"
Public Sub GetClassNameFromTitle()
Dim sInput As String, lpClassName As String
Dim nMaxCount As Long, lresult As Long, hwnd As Long
nMaxCount = 256
lpClassName = Space(nMaxCount)
sInput = InputBox("Enter the exact window title:" + Chr$(13) + Chr$(10) + "Note: must be an exact match"

hwnd = FindWindow(vbNullString, sInput)
If hwnd = 0 Then
MsgBox "Couldn't find the window."
Else
lresult = GetClassName(hwnd, lpClassName, nMaxCount)
MsgBox "Window: " + sInput + Chr$(13) + Chr$(10) + "Classname: " + Left$(lpClassName, lresult)
Debug.Print sInput & ": " & Left$(lpClassName, lresult)
End If
End Sub
'Run GetClassNameFromTitle and, if you enter the window title correctly,
'the class name will be shown in a messagebox. Once you have the window
'class name, you can always get a window handle by using FindWindow with
'the class name and vbNullString. For example:
' hwnd = FindWindow("OpusApp", vbNullString)
'...will find the hWnd for the Microsoft Word window.
'You can now activate the Word window with this function:
Public Function fActivateWindowClass(psClassname As String) As Boolean
Dim hwnd As Long
hwnd = FindWindow(psClassname, vbNullString)
If hwnd > 0 Then
ShowWindow hwnd, SW_SHOWNORMAL
fActivateWindowClass = True
End If
End Function
Have a great day!
j2consulting@yahoo.com