AppActivate Statement

Named Arguments

Yes

Syntax

AppActivate title [, wait]

title

Use: Required

Data Type: Variant

The name of the application as currently shown in the application window titlebar. Can also be the task ID returned from the Shell function.

wait

Use: Optional

Data Type: Boolean

If set to True, the calling application must itself wait to obtain the focus before activating the called application. If set to False (its default value), the application specified in title is activated immediately.

Description

Sets the focus to the application with a titlebar caption matching title. The application title passed to AppActivate isn't necessarily the name of the program file of the application; it's the name currently displayed in the application's titlebar.

Rules at a Glance

  • title isn't case sensitive.

  • The title of each running application is compared against title.

  • If the application designated by title isn't running, AppActivate doesn't launch it.

  • If no title matching title is found, an application whose title starts with title is matched. For example, the title "Microsoft Word" matches "Microsoft Word—MyDocument.doc".

  • If more than one instance of an application is found, AppActivate passes the focus to one of the instances purely at random.

  • The window state (Maximized, Minimized, or Normal) of the activated application isn't affected by AppActivate.

  • If a matching application can't be found, runtime error 5, "Invalid procedure call or argument," is generated.

  • AppActivate

Get VB & VBA in a Nutshell: The Language now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.