O'Reilly logo

VB.NET Language in a Nutshell, Second Edition by Steven Roman PhD, Paul Lomax, Ron Petrusha

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Name

AppActivate Procedure

Class

Microsoft.VisualBasic.Interaction

Syntax

[Interaction.]AppActivate(title)
title (required; String or Integer)

The name of the application as currently shown in the application window title bar. This can also be the task ID returned from the Shell function.

Description

Activates a window based on its caption

Rules at a Glance

  • AppActivate performs a case-insensitive search on all top-level windows for a window caption that matches title. If an exact match is found, the window is activated. If no match is found, then the window captions are searched for a prefix match (title matches the beginning of the window caption). For example, the title "Microsoft Word" matches "Microsoft Word - MyDocument.doc". If a prefix match is found, the window is activated. Note that if multiple prefix matches are found, there is no way to predict which matching window will be activated.

  • The window state (Maximized, Minimized, or Normal) of the activated application is not affected by AppActivate.

  • If a matching application cannot be found, an exception of type System.ArgumentException is raised, and runtime error 5, “Invalid procedure call or argument,” is generated.

Example

Private Sub Button2_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) _ Handles Button2.Click Dim bVoid As Boolean bVoid = ActivateAnApp("Microsoft Excel") End Sub Function ActivateAnApp(vAppTitle As String) As Boolean On Error GoTo Activate_Err ActivateAnApp = False AppActivate(vAppTitle) ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required