HasDiagram Property

Microsoft Excel Visual Basic

MsoTriState can be one of these MsoTriState constants.
msoCTrue Not used for this property.
msoFalse Returned if a shape is not a diagram.
msoTriStateMixed Not used for this property.
msoTriStateToggle Not used for this property.
msoTrue Returned if a shape is a diagram.

expression.HasDiagram

expression    Required. An expression that returns one of the objects in the Applies To list.

Example

The following example places a diagram in the active worksheet and then displays a message to tell the user whether the diagram was successfully created or not.

Sub CheckforDiagram()

    Dim shDiagram As Shape

    Set shDiagram = ActiveSheet.Shapes.AddDiagram( _
        Type:=msoDiagramOrgChart, Top:=10, Left:=15, _
        Width:=400, Height:=475)

    ' Notify user about diagram.
    If shDiagram.HasDiagram = msoTrue Then
        MsgBox "A diagram is present."
    Else
        MsgBox "No diagram is present."
    End If

End Sub