TabStops 对象 (Word)

表示自定义和默认制表符一个段落或一组段落的 TabStop 对象的集合。

备注

使用 TabStops 属性返回 TabStops 集合。 下面的示例清除所有自定义制表位从活动文档中的第一个段落。

ActiveDocument.Paragraphs(1).TabStops.ClearAll

下面的示例添加一个定位在所选段落的 2.5 英寸处的制表位,并显示 TabStops 集合中每个项的位置。

Selection.Paragraphs.TabStops.Add Position:=InchesToPoints(2.5) 
For Each aTab In Selection.Paragraphs.TabStops 
 MsgBox "Position = " _ 
 & PointsToInches(aTab.Position) & " inches" 
Next aTab

使用 Add 方法添加一个制表位。 下面的示例将所选段落添加两个制表位。 第一个制表位为左对齐,使用点式的制表符前导符位于 1 英寸 (72 磅)。 第二个制表位是位居中,位于 2 英寸处。

With Selection.Paragraphs.TabStops 
 .Add Position:=InchesToPoints(1), _ 
 Leader:=wdTabLeaderDots, Alignment:=wdAlignTabLeft 
 .Add Position:=InchesToPoints(2), Alignment:=wdAlignTabCenter 
End With

您还可以添加制表位 TabStops 属性指定一个位置。 下面的示例将添加位于 2 英寸到所选段落右对齐制表位。

Selection.Paragraphs.TabStops(InchesToPoints(2)) _ 
 .Alignment = wdAlignTabRight

使用 TabStops (索引) 的索引所在的位置 (以磅为单位) 的制表位或索引号,返回一个 TabStop 对象。 制表位按数字进行索引从左到右沿标尺。 下面的示例从活动文档中的第一个段落中删除第一个自定义制表位。

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

以下示例在所选段落的 2 英寸处添加一个右对齐制表位。

Selection.Paragraphs.TabStops(InchesToPoints(2)) _ 
 .Alignment = wdAlignTabRight

使用 Paragraphs 集合 (或包含多个段落的一个范围) 时,您必须修改集合中的每个段落分别如果制表位位置不一致中的所有段落。 下面的示例移除位于活动文档中各段 1 英寸处的制表位。

For Each para In ActiveDocument.Content.Paragraphs 
 para.TabStops(InchesToPoints(1)).Clear 
Next para

另请参阅

Word 对象模型参考

支持和反馈

有关于 Office VBA 或本文档的疑问或反馈? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。