Rectangle object (Word)
Represents a portion of text or a graphic in a page. Use the Rectangle object and related methods and properties for programmatically defining page layout in a document.
Use the Item method to return a specific Rectangle object. The following example accesses the first rectangle in the first page of the active document.
Dim objRectangle As Rectangle
Set objRectangle = ActiveDocument.ActiveWindow _
.Panes(1).Pages(1).Rectangles.Item(1)
Use the RectangleType property to determine the type of rectangle. The following example creates a ShapeRange object if the specified rectangle is a shape.
Dim objRectangle As Rectangle
Dim objShape As ShapeRange
Set objRectangle = ActiveDocument.ActiveWindow _
.Panes(1).Pages(1).Rectangles.Item(1)
If objRectangle.RectangleType = wdShapeRectangle Then
Set objShape = objRectangle.Range.ShapeRange
End If
Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.