Share via


Rectangle Object

Word Developer Reference

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.

Remarks

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.

Visual Basic for Applications
  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.

Visual Basic for Applications
  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

See Also