HasDiagram Property

Microsoft Excel Visual Basic

Show All

HasDiagram Property

       

 Returns whether a shape or shape range contains a diagram. Read-only MsoTriState.

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 as to whether the diagram was successfully created.

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 "Diagram present"
    Else
        MsgBox "No diagram present"
    End If

End Sub