AppFind, AppFind$ (functions)

Syntax

AppFind[$] (title | taskID)

Description

Returns a String containing the full name of the application matching either title or taskID.

Comments

The title parameter specifies the title of the application to find. If there is no exact match, BasicScript will find an application whose title begins with title.

Alternatively, you can specify the ID of the task as returned by the Shell function.

The AppFind$ functions returns a String, whereas the AppFind function returns a String variant. If the specified application cannot be found, then AppFind$ returns a zero-length string and AppFind returns Empty. Using AppFind allows you detect failure when attempting to find an application with no caption (i.e., Empty is returned instead of a zero-length String).

AppFind$ is generally used to determine whether a given application is running. The following expression returns True if Microsoft Word is running:

    AppFind$("Microsoft Word")

Example

'This example checks to see whether Excel is running before

'activating it.

Sub Main()

    If AppFind$("Microsoft Excel") <> "" Then

     AppActivate "Microsoft Excel"

    Else

     MsgBox "Excel is not running."

    End If

End Sub

Notes

This function returns a String containing the exact text appearing in the title bar of the active application's main window.

More information

A