Shapes Property

Microsoft Word Visual Basic

Returns a Shapes collection that represents all the Shape objects in the specified document, header, or footer. This collection can contain drawings, shapes, pictures, OLE objects, ActiveX controls, text objects, and callouts. Read-only.

For information about returning a single member of a collection, see Returning an Object from a Collection.

Remarks

The Shapes property, when applied to a document, returns all the Shape objects in the main story of the document, excluding the headers and footers. When applied to a HeaderFooter object, the Shapes property returns all the Shape objects found in all the headers and footers in the document.

Example

This example creates a new document, adds a rectangle to it that's 100 points wide and 50 points high, and sets the upper-left corner of the rectangle to be 5 points from the left edge and 25 points from the upper-left corner of the page.

Set myDoc = Documents.Add
myDoc.Shapes.AddShape msoShapeRectangle, 5, 25, 100, 50
		

This example sets the fill texture for all the shapes in the active document.

For each s in ActiveDocument.Shapes
    s.Fill.PresetTextured msoTextureOak
Next s
		

This example adds a shadow to the first shape in the active document.

Set myShape = ActiveDocument.Shapes(1)
myShape.Shadow.Type = msoShadow6
		

This example displays a count of all the shapes in the primary header and footer of the first section of the active document.

MsgBox ActiveDocument.Sections(1). _
    Headers(wdHeaderFooterPrimary).Shapes.Count