|
Sub 手动编号转_自动编号()
ActiveDocument.Content.ListFormat.ConvertNumbersToText
sr$ = "〇一二三四五六七八九十百千万亿"
r1$ = "[" & sr & "]@、": r2$ = "[((][" & sr & "]@[))]"
r3$ = "[0-9]@[..]": r4$ = "[((][0-9]@[))]"
a = Array(r1, r2, r3, r4)
Call ListTitle(ActiveDocument)
For j = 0 To UBound(a)
With ActiveDocument.Content.Find
Do While .Execute(a(j), , , 1)
With .Parent
If Not .Information(wdWithInTable) Then
x = Len(.Text): ksr = .Text
.Expand 4: .Collapse
If .MoveWhile(ksr, x) = x Then
.MoveStart , -x: .Text = Empty
.Style = ActiveDocument.Styles("标题 " & j + 1)
Else
.Move 4, 1
End If
End If
End With
Loop
End With
Next
End Sub
Sub ListTitle(doc As Document)
Dim LtTemp As ListTemplate, i As Integer
Set LtTemp = doc.ListTemplates.Add(True)
For i = 1 To 4
With LtTemp.ListLevels(i)
If i = 1 Then .NumberFormat = "%1、": .NumberStyle = 37
If i = 2 Then .NumberFormat = "(%2)": .NumberStyle = 37
If i = 3 Then .NumberFormat = "%3.": .NumberStyle = 0
If i = 4 Then .NumberFormat = "(%4)": .NumberStyle = 0
.TrailingCharacter = 2: .StartAt = 1: .ResetOnHigher = True
.NumberPosition = InchesToPoints(0.1 * i)
.TextPosition = InchesToPoints(0 * i)
.LinkedStyle = "标题 " & i
End With
Next
End Sub |
|