HasChildShapeRange Property
Collapse the table of content
Expand the table of content

Selection.HasChildShapeRange Property (Word)

Office 2013 and later

Contribute to this content

Use GitHub to suggest and submit changes. See our guidelines for contributing to VBA documentation.

True if the selection contains child shapes. Read-only Boolean.

expression .HasChildShapeRange

expression An expression that returns a Selection object.

This example creates a new document with a drawing canvas, populates the drawing canvas with shapes, and then, after checking that the shapes 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 
 'Fill canvas child shapes with a pattern 
 If Selection.HasChildShapeRange = True Then 
 Selection.ChildShapeRange.Fill.Patterned msoPatternDivot 
 MsgBox "This is not a range of child shapes." 
 End If 
End Sub
© 2016 Microsoft