Class TabStop (Word VBA)

The class TabStop represents a single tab stop. The TabStop object is a member of the TabStops collection. The TabStops collection represents all the custom and default tab stops in a paragraph or group of paragraphs. To use a TabStop class variable it first needs to be instantiated, for example


Dim tsp as TabStop
Set tsp = ActiveDocument.Paragraphs(1).TabStops(Index:=1)

For Each

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


Dim ts As TabStop 
For each ts in ActiveDocument.Paragraphs(1).TabStops 
 If ts.CustomTab = True Then 
 ts.Alignment = wdAlignTabLeft 
 End If 
Next ts

Alignment

Returns or sets a WdTabAlignment constant that represents the alignment for the specified tab stop. Possible return values are wdAlignTabBar - Bar-aligned, wdAlignTabCenter - Center-aligned, wdAlignTabDecimal - Decimal-aligned, wdAlignTabLeft - Left-aligned, wdAlignTabList - List-aligned, wdAlignTabRight - Right-aligned.


Sub CenterTabStop() 
 ActiveDocument.Paragraphs(1).TabStops(1) _ 
 .Alignment = wdAlignTabCenter 
End Sub

Clear

Removes the specified custom tab stop.


ActiveDocument.Paragraphs(1).TabStops(1).Clear

CustomTab

True if the specified tab stop is a custom tab stop.


Dim tsLoop As TabStop 
 
For each tsLoop in ActiveDocument.Paragraphs(1).TabStops 
 If tsLoop.CustomTab = True Then 
 tsLoop.Alignment = wdAlignTabLeft 
 End If 
Next tsLoop

Leader

Returns or sets the leader for the specified TabStop object. Possible return values are wdTabLeaderDashes - Dashes, wdTabLeaderDots - Dots, wdTabLeaderHeavy - A heavy line, wdTabLeaderLines - Double lines, wdTabLeaderMiddleDot - A middle dot, wdTabLeaderSpaces - Spaces. Default.


Dim tsLoop As TabStop 
 
For each tsLoop in ActiveDocument.Paragraphs.TabStops 
 If tsLoop.Leader <> wdTabLeaderSpaces Then 
 tsLoop.Leader = wdTabLeaderDashes 
 End If 
Next tsLoop

Next

Returns the next tabstop in the collection.


Dim tspNext As TabStop
Set tspNext = ActiveDocument.Lists(1).ListParagraphs(1).TabStops(1).Next

Position

Returns or sets the position of a tab stop relative to the left margin.


With Selection.Paragraphs.TabStops 
 .ClearAll 
 .Add Position:=InchesToPoints(2), Alignment:=wdAlignTabRight 
 MsgBox .Item(1).Position & " or " & _ 
 PointsToInches(.Item(1).Position) & " inches" 
End With

Previous

Returns the previous tab stop in the collection.


Dim tspPrevious As TabStop
Set tspPrevious = ActiveDocument.Lists(1).ListParagraphs(1).TabStops(1).Previous