Exists Method

Applies To

Bookmarks collection object, Tasks collection object.

Description

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

Syntax

expression.Exists(Name)

expression An expression that returns a Bookmarks or Tasks object.

Name Required String. A bookmark or task name.

See Also

Count property, Name property.

Example

This example determines whether the bookmark named "start" exists in the active document. If the bookmark exists, it's deleted.

If ActiveDocument.Bookmarks.Exists("start") = True Then
    ActiveDocument.Bookmarks("start").Delete
End If
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.

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