HasDiagram Property

Microsoft Word 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

This example searches the current document for diagrams with nodes and if it finds both, creates a black balloon with bold white text.

Sub HasDiagramProperties()
    Dim shpDiagram As Shape
    Dim shpNode As DiagramNode
    Dim shpBalloon As Shape
    Dim docThis As Document

    Set docThis = ThisDocument
    
    'Look through the current document and if a diagram with one
    'or more diagram nodes exists, create a balloon with text
    For Each shpDiagram In docThis.Shapes
        If shpDiagram.HasDiagram = msoTrue And _
            shpDiagram.HasDiagramNode = msoTrue Then
                Set shpBalloon = docThis.Shapes.AddShape _
                    (Type:=msoShapeBalloon, Left:=350, _
                    Top:=75, Width:=150, Height:=150)
                With shpBalloon
                    With .TextFrame.TextRange
                        .Text = "This is a diagram with nodes."
                        .Font.Color = wdColorWhite
                        .Font.Bold = True
                        .Font.Name = "Tahoma"
                        .Font.Size = 15
                    End With
                    .Line.BackColor.RGB = RGB _
                        (Red:=0, Green:=25, Blue:=25)
                    .Fill.ForeColor.RGB = RGB _
                        (Red:=0, Green:=25, Blue:=25
                End With
        End If
    Next shpDiagram
End Sub