Class Line (Word VBA)

The class Line represents an individual line in a Rectangle object of type wdTextRectangle. Use the Line object and related methods and properties to programmatically define page layout in a document. To use a Line class variable it first needs to be instantiated, for example

For Each

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


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

Height

Returns or sets the height of a line.


Dim lin As Line: Set lin =  
Dim lngHeight As Long
lngHeight = lin.Height

Left

Returns a Long that represents the number of pixels from the left edge of the page to the left edge of a line.


Dim lin As Line: Set lin =  
Dim lngLeft As Long
lngLeft = lin.Left

LineType

Returns a wdLineType constant that indicates whether a line is a text line or a table row. Possible return values are wdTableRow - A table row, wdTextLine - A line of text in the body of the document.


Dim objLine As Line 
Dim objTable As Table 
 
Set objLine = ActiveDocument.ActiveWindow _ 
 .Panes(1).Pages(1).Rectangles(1).Lines.Item(1) 
 
If objLine.LineType = wdTableRow Then _ 
 Set objTable = objLine.Range.Tables(1)

Range

Returns a Range object that represents the portion of a document that is contained within a line.


Dim lin As Line: Set lin =  
Dim rngRange As Range
Set rngRange = lin.Range

Rectangles

Returns a Rectangles collection that represents a portion of text or graphics in a page in a document.

Use the Rectangles collection and related objects and properties for programmatically defining page layout in a document. Rectangles correspond to portions of text or graphics on a page in a document.


Dim objRectangles As Rectangles 
 
Set objRectangles = ActiveDocument.ActiveWindow _ 
 .Panes(1).Pages(1).Rectangles

Top

Returns a Long that represents the number of pixels from the top of the page to the top of a line.


Dim lin As Line: Set lin =  
Dim lngTop As Long
lngTop = lin.Top

Width

Returns or sets the width, in points, of a line.


Dim lin As Line: Set lin =  
Dim lngWidth As Long
lngWidth = lin.Width