如果该属性值为 MsoTrue,则图形是一个图表。MsoTriState,只读。
MsoTriState 可以是下列 MsoTriState 常量之一: |
msoCTrue 不应用于该属性。 |
msoFalse 如果图形不是一个图表则返回该常量。 |
msoTriStateMixed 不应用于该属性。 |
msoTriStateToggle 不应用于该属性。 |
msoTrue 如果图形是一个图表则返回该属性。 |
expression.HasDiagram
expression 必需。该表达式返回“应用于”列表中的一个对象。
本示例在当前文档中查找带顶点的图表,如果找到,则创建一个有白色粗体字的黑色气球。
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