|
Sub 手动编号_自动编号()
' 多级列表链接样式的运用
Dim P As Range, S As Range
Set P = IIf(Selection.Type = wdSelectionIP, ActiveDocument.Content, Selection.Range)
If P = ActiveDocument.Content Then
k = MsgBox("要进行全文处理吗?", vbYesNoCancel + vbQuestion, "全文处理判断")
If k <> vbYes Then Exit Sub
End If
Call ListTitle(ActiveDocument)
Set S = P.Duplicate
With P.Find
Do While .Execute("[0-9]@[、..]", , , 1)
If Not P.InRange(S) Then Exit Do
With P
x = Len(.Text): ksr = .Text
.Expand 4: .Collapse
If .MoveWhile(ksr, x) = x Then
.MoveStart , -x: .Text = Empty
.Style = ActiveDocument.Styles("s")
Else
.Move 4, 1
End If
End With
Loop
End With
End Sub
Sub ListTitle(doc As Document)
Dim LtTemp As ListTemplate
Set LtTemp = doc.ListTemplates.Add(True)
On Error Resume Next
doc.Styles.Add Name:="s", Type:=1
With LtTemp.ListLevels(1)
.NumberFormat = "%1.": .NumberStyle = 0
.TrailingCharacter = 2: .StartAt = 1: .ResetOnHigher = True
.NumberPosition = InchesToPoints(0)
.TextPosition = InchesToPoints(0)
.LinkedStyle = "s"
End With
End Sub |
|