VB.NET Language in a Nutshell

   
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

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) ActivateAnApp = True Exit Function Activate_Err: MsgBox ("Application " & vAppTitle & _ " could not be activated") End Function

Programming Tips and Gotchas

VB.NET/VB 6 Differences

In VB 6, AppActivate has a second optional parameter, wait , a Boolean that determines whether the application calling AppActivate must have the focus for the window indicated by title to be activated. In VB.NET, wait is not supported.

See Also

Shell Function

   

Категории