expression.IsValidObject(Object)
expression Required. An expression that returns one of the objects in the Applies To list.
Object Required Object. A variable that references an object.
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 above subroutine.
Sub CallValidShape()
Call ValidShape(shpObject:=ActiveDocument.Pages(1).Shapes(2))
End Sub