Word VBA教程:ChildShapeRange属性

返回一个 ShapeRange对象,该对象代表选定区域的子图形。

expression.ChildShapeRange

expression   必需。该表达式返回一个Selection对象。

VBA示例

本示例创建一个带画布的新文档,在画布上添加图形,然后,在检查选定图形是子图形之后,使用图案填充子图形。


Sub ChildShapes()
    Dim docNew As Document
    Dim shpCanvas As Shape
    'Create a new document with a drawing canvas and shapes
    Set docNew = Documents.Add
    Set shpCanvas = docNew.Shapes.AddCanvas( _
        Left:=100, Top:=100, Width:=200, Height:=200)
    shpCanvas.CanvasItems.AddShape msoShapeRectangle, _
        Left:=0, Top:=0, Width:=100, Height:=100
    shpCanvas.CanvasItems.AddShape msoShapeOval, _
        Left:=0, Top:=50, Width:=100, Height:=100
    shpCanvas.CanvasItems.AddShape msoShapeDiamond, _
        Left:=0, Top:=100, Width:=100, Height:=100
    'Select all shapes in the canvas
    shpCanvas.CanvasItems.SelectAll
    'Fill canvas child shapes with a pattern
    If Selection.HasChildShapeRange = True Then
        Selection.ChildShapeRange.Fill.Patterned msoPatternDivot
    Else
        MsgBox "This is not a range of child shapes."
    End If
End Sub

Word VBA教程

Word VBA参考教程:目录1 Word VBA参考教程:目录2
Word VBA参考教程:目录3 Word VBA参考教程:目录4
Word VBA参考教程:目录5 Word VBA参考教程:目录6
Word VBA参考教程:目录7 Word VBA参考教程:目录8
Word VBA参考教程:目录9 Word VBA参考教程:目录10
版权所有 © 中山市飞娥软件工作室 证书:粤ICP备09170368号