Class Rectangle (Word VBA)

The class Rectangle 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.

For Each

Here is an example of processing the Rectangle items in a collection.

Dim lin As Line: Set lin = 
Dim shp As Rectangle
For Each shp In lin.Rectangles
	With shp
		
	End With
Next shp

Properties

Height returns a Long that represents the height of a rectangle, in pixels.

7 
Dim lngHeight As Long
lngHeight = shp.Height

Left returns a Long that represents the number of pixels from the left edge of the page to the left edge of a rectangle.

7 
Dim lngLeft As Long
lngLeft = shp.Left

Lines returns a Lines collection that represents the lines in a specified portion of text in a page.

7 
Dim lnsLines As Lines
Set lnsLines = shp.Lines

Parent returns an object that represents the parent object of the specified Rectangle object.

7 
Dim objParent As Object
Set objParent = shp.Parent

Range returns a Range object that represents the portion of a document that is contained within a rectangle.

7 
Dim rngRange As Range
Set rngRange = shp.Range

RectangleType returns a WdRectangleType constant that represents the type for the specified rectangle.

7 
Dim wrtRectangleType As WdRectangleType
wrtRectangleType = shp.RectangleType

Top returns a Long that represents the number of pixels from the top of the page to the top of a rectangle.

7 
Dim lngTop As Long
lngTop = shp.Top

Width returns or sets a Long that represents the width, in points, of a rectangle.

7 
Dim lngWidth As Long
lngWidth = shp.Width

Rectangles.Count returns a Long that represents the number of rectangles in the collection.

Dim rcts As Rectangles: Set rcts =  
Dim lngCount As Long
lngCount = rcts.Count

Rectangles.Parent returns an object that represents the parent object of the specified Rectangles object.

Dim rcts As Rectangles: Set rcts =  
Dim objParent As Object
Set objParent = rcts.Parent