在word中制表位可以用于快速地定位、排版字符。
打开“制表位”对话框,如下图所示:

可以看到当前的默认制表位为2个字符单位,可以通过Document 对象的 DefaultTabStop 属性修改。
Sub QQ1722187970()
Dim oDoc As Document
Set oDoc = Word.ActiveDocument
With oDoc
iOld = .DefaultTabStop
'设置默认的制表位为原来制表位的2倍
.DefaultTabStop = iOld * 2
End With
End Sub
如果要新增自定义制表位,可以使用TabStops对象的 Add方法。
Sub QQ1722187970()
Dim oDoc As Document
Set oDoc = Word.ActiveDocument
Dim oSec As Section
Dim oRng As Range
Dim oP As Paragraph
Dim oTS As TabStop
With oDoc
Set oRng = .Paragraphs(2).Range
Set oTS = oRng.ParagraphFormat.TabStops.Add(380, wdAlignTabLeft, wdTabLeaderDots)
With oTS
.Alignment = wdAlignTabLeft
.Leader = wdTabLeaderDots
'是否是自定义制表位
Debug.Print .CustomTab
End With
End With
End Sub


发表评论