How can I find the Classname of an app that is not listed in this Select statement?

In the fIsAppRunning function that is described in PAQ (http://www.experts-exchange.com/Microsoft/Development/MS_Access/Q_20564558.htm) how can I determine what the classname is of a different app like Adobe Acrobat so I cam set strClassName.

strClassName = "Acrobat" -> Does not work

Select Case LCase$(strAppName)
        Case "Acrobat":              strClassName = "Acrobat"
        Case "excel":                  strClassName = "XLMain"
        Case "word":                  strClassName = "OpusApp"
        Case "access":               strClassName = "OMain"
        Case "powerpoint95":     strClassName = "PP7FrameClass"
        Case "powerpoint97":     strClassName = "PP97FrameClass"
        Case "notepad":              strClassName = "NOTEPAD"
        Case "paintbrush":          strClassName = "pbParent"
        Case "wordpad":            strClassName = "WordPadClass"
        Case Else:                       strClassName = vbNullString
End Select

Open in new window

scuzz1Asked:
Who is Participating?
 
MikeTooleCommented:
This is extracted from
http://www.adobe.com/devnet/illustrator/pdfs/illustrator_scripting_reference_vbscript.pdf
- not sure if it will help.
The Adobe Illustrator application object, which contains all other Illustrator objects.
NOTE: If you have both earlier and later versions of Illustrator installed on the same machine and use the
CreateObject() or GetObject() method to obtain an application reference, use the optional numeric
version identifier at the end of the string Illustrator.Application. When the version identifier is not
present, the string refers to the latest installed Illustrator version. To specifically target a version:
¤ For Illustrator 10, use Illustrator.Application.1
¤ For Illustrator CS, use Illustrator.Application.2
¤ For Illustrator CS2, use Illustrator.Application.3
¤ For Illustrator CS3, use Illustrator.Application.4
¤ For Illustrator CS4, use Illustrator.Application.5 (same as Illustrator.Application)
0
 
Simon BallCommented:
Case Else:              msgbox         strClassName

will this identify?
0
 
Simon BallCommented:
sorry
msgbox strAppName not strclassname
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
You're passing a value INTO the Select Case statement, and taking action based on that. I don't see how you can determine what class is running UNLESS you pass in the name of that class (i.e. the strAppName variable).

What exactly is this code supposed to do?
0
 
Simon BallCommented:
your PAQ url goes to a page not found error.
0
 
MikeTooleCommented:
Are you using Acrobat? - Adobe Reader doesn't support OLE automation
See this document on Inter-application communication
http://partners.adobe.com/public/developer/en/acrobat/sdk/pdf/iac/IACOverview.pdf
0
 
scuzz1Author Commented:
Sorry about the link. This is the code I am referring to. It is using apiFindWindow and passes that function either the (i'm guessing here) Application Name in strAppName or the Application's Class Name in strClassName. The program that I want to check for is Tech Illustrator. TI.exe is the program to execute but for some reason I cannot determine what to pass to the apiFindWindow function to tell whether or not it is running. I cannot even get it to tell me if Acrobat is running.

Jim

Private Const SW_SHOWNORMAL = 1
Private Const SW_NORMAL = 1
Private Const SW_SHOWMINIMIZED = 2
Private Const SW_SHOWMAXIMIZED = 3
 
Private Declare Function apiFindWindow Lib "user32" Alias _
    "FindWindowA" (ByVal strClass As String, _
    ByVal lpWindow As String) As Long
 
Private Declare Function apiSendMessage Lib "user32" Alias _
    "SendMessageA" (ByVal Hwnd As Long, ByVal Msg As Long, ByVal _
    wParam As Long, lParam As Long) As Long
   
Private Declare Function apiSetForegroundWindow Lib "user32" Alias _
    "SetForegroundWindow" (ByVal Hwnd As Long) As Long
   
Private Declare Function apiShowWindow Lib "user32" Alias _
    "ShowWindow" (ByVal Hwnd As Long, ByVal nCmdShow As Long) As Long
   
Private Declare Function apiIsIconic Lib "user32" Alias _
    "IsIconic" (ByVal Hwnd As Long) As Long
   
Function fIsAppRunning(ByVal strAppName As String, _
        Optional fActivate As Boolean) As Boolean
 
    Dim lngH As Long
    Dim strClassName As String
    Dim lngX As Long
    Dim lngTmp As Long
 
    Const WM_User = 1024
 
    On Local Error GoTo fIsAppRunning_Err
 
    Select Case LCase$(strAppName)
        Case "excel":        strClassName = "XLMain"
        Case "word":         strClassName = "OpusApp"
        Case "access":       strClassName = "OMain"
        Case "powerpoint95": strClassName = "PP7FrameClass"
        Case "powerpoint97": strClassName = "PP97FrameClass"
        Case "notepad":      strClassName = "NOTEPAD"
        Case "paintbrush":   strClassName = "pbParent"
        Case "wordpad":      strClassName = "WordPadClass"
        Case Else:           strClassName = ""
    End Select
   
    If strClassName = "" Then
        ' Use what was given.
        lngH = apiFindWindow(vbNullString, strAppName)
    Else
        ' Use the Class Name substituted by the Select Case.
        lngH = apiFindWindow(strClassName, vbNullString)
    End If
 
    If lngH <> 0 Then
        apiSendMessage lngH, WM_USER + 18, 0, 0
        lngX = apiIsIconic(lngH)
 
        If lngX <> 0 Then _
            lngTmp = apiShowWindow(lngH, SW_SHOWNORMAL)
 
        If fActivate Then _
            lngTmp = apiSetForegroundWindow(lngH)
 
        fIsAppRunning = True
    End If
 
fIsAppRunning_Exit:
    Exit Function
 
fIsAppRunning_Err:
    fIsAppRunning = False
    Resume fIsAppRunning_Exit
 
End Function

Open in new window

0
 
scuzz1Author Commented:
>>> You're passing a value INTO the Select Case statement, and taking action based on that.
I don't see how you can determine what class is running UNLESS you pass in the name of that class (i.e. the strAppName variable).

I understand that. What I am asking is how can I find out what the classname of an application is so I can pass it to the function.

Jim

0
 
MikeTooleCommented:
Sorry, I can't find any reference source for the illustrator classname
0
 
scuzz1Author Commented:
I wonder if everyone understands what I am asking.

How did the author of this code know that Excel's classname is XLMain or paintbrush is PBParent. Is there somewhere that one can look that information up?
0
 
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
The developer of the utility/program would be the best source. If you're looking for Illustrator, www.adobe.com would be the place to look.
0
 
scuzz1Author Commented:
You would think that "Adobe" or "Acrobat" or "Acrobat 8.0" would be the "AppName" but I have tried every name I can think of and the function does not recognize it. Even for Autotrols Tech Illustrator, I have tried "TI", Tech Illustrator Plus" (which is the name at the top of the window) but nothing works. I am starting to think that that function only works with the programs listed in the select statement.

Jim
0
 
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
Mike has done the heavy lifting for you on this; as I said, you often need to go back to the vendor to find out exactly what to use. There is no master list, as far as I know.

One method you might use is this:

Temporarily add a Reference in your project to the item you wish to work with. Now declare a variable and use Intellisense to see if you can locate the classname. IOW, type this:

Dim obj As

And Intellisense should present to you a listing of the various objects available for use. Once you know the object name, make sure to remove that reference.
0
 
scuzz1Author Commented:
Sorry about the delay's in responding. I have been pretty busy. I am going to research what Mike has suggested and see what I can dig up. I will get back.

Thanks for all your efforts. I really do appreciate it.
Jim
0
 
scuzz1Author Commented:
Thanks,

I am going to go with your suggestion on the GetObject() method. It may take a while for me to get it to work for me but I'll get.

Thanks Again,
Jim
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.