AutoFormat Property

Microsoft Excel Visual Basic

constant indicating the automatic formatting state for a diagram. Read/write.

MsoTriState can be one of these MsoTriState constants.
msoCTrue Does not apply to this property.
msoFalse Disables automatic formatting for the diagram.
msoTriStateMixed Does not apply to this property.
msoTriStateToggle Does not apply to this property.
msoTrue Enables automatic formatting for the diagram.

expression.AutoFormat

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

Example

This example creates a diagram in the current document and turns on the automatic format for the diagram.

Sub CreatePyramidDiagram()
    Dim dgnNode As DiagramNode
    Dim shpDiagram As Shape
    Dim intCount As Integer

    'Add a pyramid diagram to current document.
    Set shpDiagram = ActiveSheet.Shapes.AddDiagram( _
        Type:=msoDiagramPyramid, _
        Left:=10, _
        Top:=15, _
        Width:=400, _
        Height:=475)

    'Add first child node.
    Set dgnNode = shpDiagram.DiagramNode.Children.AddNode

    'Add three more child nodes
    For intCount = 1 To 3
        dgnNode.AddNode
    Next intCount

    'Enable automatic formatting for the diagram and convert
    'it to a radial diagram.
    With dgnNode.Diagram
        .AutoFormat = msoTrue
        .Convert Type:=msoDiagramRadial
    End With

End Sub