以下代码为应用于某些ISO文件,可以通过代码定义原有多级编号,并指定特定格式(或者样式),代码中为格式。
适用场合:原未用自动编号的文件,并且没有图形或者图片(可能会有所影响),代码中设置为四级编号。如有问题请及时交流!
'* +++++++++++++++++++++++++++++
'* Created By 守柔(ShouRou)@ExcelHome 2005-2-19 16:39:36
'仅测试于System: Windows NT Word: 10.0 Language: 2052
'^The Code CopyIn [ThisDocument-ThisDocument]^'
'* -----------------------------
Sub Sample()
Dim listgal As ListGallery, N As Byte, i As Paragraph, myListTemp As ListTemplate
For Each listgal In ListGalleries '将每个列表模板库中的模板重新设置为内置模板
For N = 1 To 7
listgal.Reset (N)
Next N
Next listgal
Application.ScreenUpdating = False '关闭屏幕更新
'定义一个多级符号的列表样式(第六个,"无"不算,为第五个)
Set myListTemp = ListGalleries(wdOutlineNumberGallery).ListTemplates(5)
For Each i In Me.Paragraphs '在段落中循环
With i.Range
If i.Range Like "#.#.#.#*" Then '应用列表模板并重设字体等格式
.ListFormat.ApplyListTemplate ListTemplate:=myListTemp
.Font.Name = "宋体": .Font.Bold = False
ElseIf i.Range Like "#.#.#*" Then
.ListFormat.ApplyListTemplate ListTemplate:=myListTemp
.Font.Name = "宋体": .Font.Bold = False
ElseIf i.Range Like "#.#*" Then
.ListFormat.ApplyListTemplate ListTemplate:=myListTemp
.Font.Name = "宋体": .Font.Bold = False
ElseIf i.Range Like "#*" Then '一级编号为黑体加粗字
.ListFormat.ApplyListTemplate ListTemplate:=myListTemp
.Font.Name = "黑体": .Font.Bold = True
Else
.Font.Name = "宋体": .Font.Bold = False
End If
End With
Next
With ActiveDocument.Content
.Font.Size = 12 '设置文档字体
.Paragraphs.Space15 '设置行距
.Paragraphs.SpaceAfter = 0 '段后为0
.Paragraphs.SpaceBefore = 0 '段前为0
End With
Application.ScreenUpdating = True '恢复屏幕更新
End Sub
'----------------------
编辑了一下贴子主题,以突出自动编号,利用以后搜索。
[此贴子已经被作者于2005-2-20 5:36:23编辑过] |