|
楼主 |
发表于 2023-3-1 02:30
|
显示全部楼层
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
楼上朋友,你好!——请在正常操作之后,执行下面的补丁程序,即可将章下面的节号重排为 1(注意:请将代码复制到空白文档后,全选,剪切,再粘贴到 VBE 中再使用,以免汉字有乱码)。默认“节”字段落排版后是标题 2,现在降为标题 3,但格式可能有问题(有问题请反馈)。
- Sub a0301_AutoNumRestart()
- '章下节号重排
- Const s As String = "[一二三四五六七八九十百零千]"
- Dim i As Paragraph, n&, k&
- For Each i In ActiveDocument.Paragraphs
- With i.Range
- If .Text Like "第" & s & "章*" Or _
- .Text Like "第" & s & s & "章*" Or _
- .Text Like "第" & s & s & s & "章*" Or _
- .Text Like "第" & s & s & s & s & "章*" Or _
- .Text Like "第" & s & s & s & s & s & "章*" Then n = 0
- If .Text Like "第" & s & "节*" Or _
- .Text Like "第" & s & s & "节*" Or _
- .Text Like "第" & s & s & s & "节*" Or _
- .Text Like "第" & s & s & s & s & "节*" Or _
- .Text Like "第" & s & s & s & s & s & "节*" Then
- n = n + 1
- ActiveDocument.Range(i.Range.Start, i.Range.Characters(InStr(i.Range.Text, "节")).End - 1).Delete
- With .Characters(1)
- .Fields.Add Range:=.Paragraphs(1).Range, Text:="= " & n & " \* CHINESENUM3"
- .Fields.Unlink
- .InsertBefore Text:="第"
- End With
- .Style = wdStyleHeading3
- End If
- End With
- Next
- '''
- With ActiveDocument.Styles(wdStyleHeading3).Font
- ' .NameFarEast = "宋体"
- ' .NameAscii = "Times New Roman"
- .ColorIndex = wdGreen
- End With
- ActiveDocument.Styles(wdStyleHeading3).ParagraphFormat.Alignment = wdAlignParagraphCenter
- End Sub
复制代码 |
|