Syntax
AppActivate WindowName$ [, Immediate]
Remarks
Activates a running application.
Argument | Explanation |
WindowName$ | In Windows, the name of the application window to activate, as it appears in the title bar or Task List. It is not necessary to specify the entire window name. For example, to indicate a window named "Notepad - FILES.TXT," you can specify "Notepad - FILES.TXT," "Notepad," or even "Note." The first window name in the Task List that matches the beginning of the specified string is affected. The case of characters is not significant in WindowName$. On the Macintosh, WindowName$ is the application name or the signature returned by the MacID$() function. It is generally preferable to use the signature instead of the application name (for example, MacID$("XCEL") instead of "Microsoft Excel") because, unlike the application name, the signature never changes. |
Immediate | Specifies when to switch to the other application: 0 (zero) or omitted If Word is not active, Word flashes its title bar or icon, waits for the user to activate Word, and then activates the other application. 1 Word immediately activates the other application, even if Word is not the active application. |
Example
This Windows example activates File Manager if it is running and starts File Manager if it is not running:
If AppIsRunning("File Manager") Then AppActivate "File Manager" Else Shell "WINFILE.EXE" End If
This Macintosh example activates Microsoft Excel if it is running and starts Microsoft Excel if it is not running.
If AppIsRunning(MacID$("XCEL") Then AppActivate MacID$("XCEL") Else Shell MacID$("XCEL") End If
Note that the Macintosh example could be shortened to Shell MacID$("XCEL") because, unlike in Windows, Shell on the Macintosh does not start a second instance of an application if it is already running.
See Also
AppClose, AppGetNames, AppIsRunning(), MacID$(), MicrosoftApplication, Shell