Class TabStops (Word VBA)

A collection of TabStop objects that represent the custom and default tabs for a paragraph or group of paragraphs.

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

Dim tss as TabStops
Set tss = ActiveDocument.Paragraphs(1).TabStops

The following procedures can be used to set variables of type TabStops: Paragraph.TabStops, ParagraphFormat.TabStops and Paragraphs.TabStops.

For Each

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

Dim tsp As TabStop
For Each tsp In ActiveDocument.Lists(1).ListParagraphs(1).TabStops
	
Next tsp

Add

Returns a TabStop object that represents a custom tab stop added to a document.

Add (Position, Alignment, Leader)

Selection.Paragraphs.TabStops.Add Position:=InchesToPoints(2.5)

Arguments

The following argument is required

Position (Single) - The position of the tab stop (in points) relative to the left margin.

Optional arguments

The following arguments are optional

Alignment (WdTabAlignment) - The alignment of the tab stop. Can be one of the WdTabAlignment constants.


Possible values are

wdAlignTabBar Bar-aligned.
wdAlignTabCenter Center-aligned.
wdAlignTabDecimal Decimal-aligned.
wdAlignTabLeft Left-aligned.
wdAlignTabList List-aligned.
wdAlignTabRight Right-aligned.

Leader (WdTabLeader) - The type of leader for the tab stop. Can be one of the WdTabLeader constants. If this argument is omitted, wdTabLeaderSpaces is used.


Possible values are

wdTabLeaderDashes Dashes.
wdTabLeaderDots Dots.
wdTabLeaderHeavy A heavy line.
wdTabLeaderLines Double lines.
wdTabLeaderMiddleDot A middle dot.
wdTabLeaderSpaces Spaces. Default.

After

Returns the next TabStop object to the right of Position.

After (Position)

Position: A location on the ruler, in points.

Dim tabTemp as TabStop 
 
Set tabTemp = ActiveDocument.Paragraphs(1).TabStops _ 
 .After(InchesToPoints(1)) 
 
tabTemp.Alignment = wdAlignTabCenter

Before

Returns the next TabStop object to the left of Position.

Before (Position)

Position: A location on the ruler, in points.

Dim tsTemp As TabStop 
 
Set tsTemp = ActiveDocument.Paragraphs(1) _ 
 .TabStops.Before(InchesToPoints(2)) 
tsTemp.Alignment = wdAlignTabCenter

ClearAll

Clears all the custom tab stops from the specified paragraphs.

To clear an individual tab stop, use the Clear method of the TabStop object. The ClearAll method doesn't clear the default tab stops. To manipulate the default tab stops, use the DefaultTabStop property for the document.

ActiveDocument.Paragraphs.TabStops.ClearAll

Count

Returns a Long that represents the number of tab stops in the collection.

Dim lngCount As Long
lngCount = ActiveDocument.Lists(1).ListParagraphs(1).TabStops.Count

Item

Returns an individual TabStop object in a collection.

Item (Index)

Index: The individual object to be returned. Can be a Long indicating the ordinal position or a String representing the name of the individual object.

Dim tsp As TabStop
Set tsp = ActiveDocument.Lists(1).ListParagraphs(1).TabStops(Index:=1)