Class Row (Word VBA)

The class Row represents a row in a table. The Row object is a member of the Rows collection. The Rows collection includes all the rows in the specified selection, range, or table.

The main procedures of class Row are Delete, Select, Rows.Add, Rows.Delete and Rows.Select

Set

To use a Row class variable it first needs to be instantiated, for example

Dim rw as Row
Set rw = ActiveDocument.Range.Rows(Index:=1)

The following procedures can be used to set variables of type Row: Cell.Row, Next, Previous, Rows.Add, Rows.Item, Rows.First, Rows.Last, Range.Rows, Selection.Rows and Table.Rows

For Each

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

Dim rw As Row
For Each rw In ActiveDocument.Range.Rows
	
Next rw

Themes

Some procedures in this class have been grouped together in themes and are described on separate theme pages

Format with its procedures Borders, HeadingFormat, HeightRule, SetHeight, Rows.Borders, Rows.DistributeHeight, Rows.HeadingFormat, Rows.HeightRule and Rows.SetHeight
Column with its procedures SpaceBetweenColumns and Rows.SpaceBetweenColumns

Methods

These are the main methods of the Row class

Delete - Deletes the specified table row.

ActiveDocument.Range.Rows(1).Delete

Select - Selects the specified table row.

ActiveDocument.Range.Rows(1).Select

Rows.Add - Returns a Row object that represents a row added to a table.

Dim rw As Row
Set rw = ActiveDocument.Range.Rows.Add()

Rows.Delete - Deletes the specified table rows.

ActiveDocument.Range.Rows.Delete

Rows.Select - Selects a collection of rows in a table.

ActiveDocument.Range.Rows.Select

Other Methods

ConvertToText - Converts a table to text and returns a Range object that represents the delimited text.

Dim rngConvertToText As Range
Set rngConvertToText = ActiveDocument.Range.Rows(1).ConvertToText()

SetLeftIndent - Sets the indentation for a row in a table.

ActiveDocument.Range.Rows(1).SetLeftIndent LeftIndent:=, RulerStyle:=wdAdjustFirstColumn

Rows.ConvertToText - Converts rows in a table to text and returns a Range object that represents the delimited text.

Dim rngConvertToText As Range
Set rngConvertToText = ActiveDocument.Range.Rows.ConvertToText()

Rows.SetLeftIndent - Sets the indentation for a row or rows in a table.

ActiveDocument.Range.Rows.SetLeftIndent LeftIndent:=, RulerStyle:=wdAdjustFirstColumn

Properties

Alignment returns or sets a WdRowAlignment constant that represents the alignment for the specified rows.

ActiveDocument.Range.Rows(1).Alignment = wdAlignRowCenter

AllowBreakAcrossPages true if the text in a table row or rows are allowed to split across a page break.

ActiveDocument.Range.Rows(1).AllowBreakAcrossPages =

Cells returns a Cells collection that represents the table cells in a column, row, selection, or range.

Dim cllsCells As Cells
Set cllsCells = ActiveDocument.Range.Rows(1).Cells

Height returns or sets the height (in points) of the specified row in a table.

ActiveDocument.Range.Rows(1).Height =

ID returns or sets the identifying label for the specified table row when the document is saved as a webpage.

ActiveDocument.Range.Rows(1).ID =

Index returns a Long that represents the position of an item in a collection.

Dim lngIndex As Long
lngIndex = ActiveDocument.Range.Rows(1).Index

IsFirst true if the specified row is the first one in the table.

Dim booIsFirst As Boolean
booIsFirst = ActiveDocument.Range.Rows(1).IsFirst

IsLast true if the specified row is the last one in the table.

Dim booIsLast As Boolean
booIsLast = ActiveDocument.Range.Rows(1).IsLast

LeftIndent returns or sets a Single that represents the left indent value (in points) for the specified table row.

ActiveDocument.Range.Rows(1).LeftIndent =

NestingLevel returns the nesting level of the specified table row.

Dim lngNestingLevel As Long
lngNestingLevel = ActiveDocument.Range.Rows(1).NestingLevel

Next returns a Row object that represents the table row that is next in the collection of rows in a table.

Dim rwNext As Row
Set rwNext = ActiveDocument.Range.Rows(1).Next

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

Dim objParent As Object
Set objParent = ActiveDocument.Range.Rows(1).Parent

Previous returns a Row object that represents the table row that is previous to the specified row.

Dim rwPrevious As Row
Set rwPrevious = ActiveDocument.Range.Rows(1).Previous

Range returns a Range object that represents the portion of a document that is contained within the specified table row.

Dim rngRange As Range
Set rngRange = ActiveDocument.Range.Rows(1).Range

Shading returns a Shading object that refers to the shading formatting for the specified object.

Dim shdShading As Shading
Set shdShading = ActiveDocument.Range.Rows(1).Shading

Rows.Alignment returns or sets a WdRowAlignment constant that represents the alignment for the specified rows.

ActiveDocument.Range.Rows.Alignment = wdAlignRowCenter

Rows.AllowBreakAcrossPages true if the text in a table row or rows are allowed to split across a page break.

ActiveDocument.Range.Rows.AllowBreakAcrossPages =

Rows.AllowOverlap returns or sets a value that specifies whether the specified rows can overlap other rows.

ActiveDocument.Range.Rows.AllowOverlap =

Rows.Count returns a Long that represents the number of rows in the collection.

Dim lngCount As Long
lngCount = ActiveDocument.Range.Rows.Count

Rows.DistanceBottom returns or sets the distance (in points) between the document text and the bottom edge of the specified table.

ActiveDocument.Range.Rows.DistanceBottom =

Rows.DistanceLeft returns or sets the distance (in points) between the document text and the left edge of the specified table.

ActiveDocument.Range.Rows.DistanceLeft =

Rows.DistanceRight returns or sets the distance (in points) between the document text and the right edge of the specified table.

ActiveDocument.Range.Rows.DistanceRight =

Rows.DistanceTop returns or sets the distance (in points) between the document text and the top edge of the specified table.

ActiveDocument.Range.Rows.DistanceTop =

Rows.First returns a Row object that represents the first item in the Rows collection.

Dim rwFirst As Row
Set rwFirst = ActiveDocument.Range.Rows.First

Rows.Height returns or sets the height of the specified rows in a table.

ActiveDocument.Range.Rows.Height =

Rows.HorizontalPosition returns or sets the horizontal distance between the edge of the rows and the item specified by the RelativeHorizontalPosition property.

ActiveDocument.Range.Rows.HorizontalPosition =

Rows.Last returns the last item in the Rows collection as a Row object.

Dim rwLast As Row
Set rwLast = ActiveDocument.Range.Rows.Last

Rows.LeftIndent returns or sets a Single that represents the left indent value (in points) for the specified table rows.

ActiveDocument.Range.Rows.LeftIndent =

Rows.NestingLevel returns the nesting level of the specified table rows.

Dim lngNestingLevel As Long
lngNestingLevel = ActiveDocument.Range.Rows.NestingLevel

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

Dim objParent As Object
Set objParent = ActiveDocument.Range.Rows.Parent

Rows.RelativeHorizontalPosition specifies the relative horizontal position of a group of rows.

ActiveDocument.Range.Rows.RelativeHorizontalPosition = wdRelativeHorizontalPositionCharacter

Rows.RelativeVerticalPosition specifies the relative vertical position of a group of rows.

ActiveDocument.Range.Rows.RelativeVerticalPosition = wdRelativeVerticalPositionBottomMarginArea

Rows.Shading returns a Shading object that refers to the shading formatting for the specified object.

Dim shdShading As Shading
Set shdShading = ActiveDocument.Range.Rows.Shading

Rows.TableDirection returns or sets the direction in which Microsoft Word orders cells in the specified table or row.

ActiveDocument.Range.Rows.TableDirection = wdTableDirectionLtr

Rows.VerticalPosition returns or sets the vertical distance between the edge of the rows and the item specified by the RelativeVerticalPosition property.

ActiveDocument.Range.Rows.VerticalPosition =

Rows.WrapAroundText returns or sets whether text should wrap around the specified rows.

ActiveDocument.Range.Rows.WrapAroundText =