ChildShapeRange 属性 (Word)Selection.ChildShapeRange property (Word)

返回一个**ShapeRange** 集合, 该集合代表所选内容中包含的子图形。Returns a ShapeRange collection representing the child shapes contained within a selection.

语法Syntax

expressionexpression. ChildShapeRange

_表达式_一个返回**Selection** 对象的表达式。expression An expression that returns a Selection object.

示例Example

本示例创建一个带绘图画布的新文档,在绘图画布上添加图形,然后,在检查选定图形是子图形之后,使用图案填充子图形。This example creates a new document with a drawing canvas, populates the drawing canvas with shapes, and then, after checking that the shapes selected are child shapes, fills the child shapes with a pattern.

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

另请参阅See also

Selection 对象Selection Object

支持和反馈Support and feedback

有关于 Office VBA 或本文档的疑问或反馈?Have questions or feedback about Office VBA or this documentation? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.