Compartilhar via


Tasks.Exists Method

Word Developer Reference

Determines whether the specified task exists. Returns True if the task exists.

Syntax

expression.Exists(Name)

expression   A variable that represents a Tasks collection.

Parameters

Name Required/Optional Data Type Description
Name Required String The name of the task.

Return Value
Boolean

Example

This example determines whether the Windows Calculator program is running (if the task exists). If Calculator isn't running, the Shell statement starts it. If Calculator is running, the application is activated.

Visual Basic for Applications
  If Tasks.Exists("Calculator") = False Then
    Shell "Calc.exe"
Else
    Tasks("Calculator").Activate
End If
Tasks("Calculator").WindowState = wdWindowStateNormal

See Also