Application.IsValidObject method (Publisher)

Determines whether the specified object variable references a valid object and returns a Boolean value: True if the specified variable that references an object is valid, and False if the object referenced by the variable has been deleted.

Syntax

expression.IsValidObject (Object)

expression A variable that represents an Application object.

Parameters

Name Required/Optional Data type Description
Object Required Object A variable that references an object.

Return value

Boolean

Example

This example formats the line of a valid object.

Sub ValidShape(shpObject As Shape) 
 
 If Application.IsValidObject object:=shpObject) = True Then 
 With shpObject.Line 
 .DashStyle = msoLineRoundDot 
 .ForeColor.RGB = RGB(Red:=158, Green:=50, Blue:=208) 
 .Weight = 5 
 End With 
 End If 
 
End Sub

Use the following subroutine to call the subroutine in the previous example.

Sub CallValidShape() 
 Call ValidShape(shpObject:=ActiveDocument.Pages(1).Shapes(2)) 
End Sub

Support and feedback

Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.