AppActivate Statement

Description

Activates an application window.

Syntax

AppActivate title [,wait]

The AppActivate statement syntax has these named-argument parts:

Part

Description

title

In Microsoft Windows, the title argument is the string in the title bar of the application window you want to activate.

On the Macintosh (System 7.0 or later), the title argument is the application name. You can use the MacID function to specify an application's signature instead of the application name. For example,

AppActivate MacID("MSWD")

In addition, the task ID returned by the Shell function can be used, in place of title, to activate an application.

wait

Boolean value specifying whether the calling application has the focus before activating another. If False (default), the specified application is immediately activated, even if the calling application does not have the focus. If True, the calling application waits until it has the focus, then activates the specified application.


Remarks

The AppActivate statement changes the focus to the named application or window but does not affect whether it is maximized or minimized. Focus moves from the activated application window when the user takes some action to change the focus or close the window. Use the Shell function to start an application and set the window style.

In trying to find the application to activate, a comparison is made to try to find an application whose title string is an exact match with title. If unsuccessful, any application's title string that begins with title is activated. In Microsoft Windows, if there is more than one instance of the application named by title, one is arbitrarily activated.

If you use the MacID function with AppActivate in Microsoft Windows, an error occurs.

See Also

MacID Function, SendKeys Statement, Shell Function.

Example

This example illustrates various uses of the AppActivate statement to activate an application window. On the Macintosh, you can use the MacID function to specify the application's signature instead of the application's name. The AppActivate statement is available with Macintosh System 7.0 or later.


' In Microsoft Windows.
AppActivate "Microsoft Word"    ' Activate Word.
' AppActivate can also use the return value of the Shell function.
MyAppID = Shell("C:\WORD\WINWORD.EXE", 1)    ' Run Microsoft Word.
AppActivate MyAppID    ' Activate Microsoft 
    ' Word.

' On the Macintosh.
AppActivate "Microsoft Word"    ' Activate Microsoft 
    ' Word.
' MacID("MSWD") returns signature for Microsoft Word.
AppActivate MacID("MSWD")    ' Activate Microsoft 
    ' Word.
' You can also use the return value of the Shell function.
ReturnValue = Shell("Microsoft Excel")    ' Run Microsoft Excel.
AppActivate ReturnValue    ' Activate Microsoft 
    ' Excel.