- Sub aaaa报告编号()
- Dim s$
- s = InputBox("格式:2020101607-V1", "请输入新的<报告编号>!", "2021010715-V2")
- If s = "" Then End
- With ActiveDocument.Content.Find
- .Execute "^12", , , 0, , , , , , "", 2
- .Execute "检测报告^p", , , 0, , , , , , "^12^&", 2
- .Execute "(报告编号^9)(*)(^9)(*)(^13)", , , 1, , , , , , "\1" & s & "\3\5", 2
- End With
- With Selection
- .HomeKey 6
- With .Find
- .ClearFormatting
- .Text = "(报告编号^9)(*)(^9)(^13)"
- .Replacement.Text = ""
- .Forward = True
- .MatchWildcards = True
- Do While .Execute
- With .Parent
- .EndKey
- .TypeText Text:="第 "
- .Fields.Add Range:=.Range, Type:=wdFieldEmpty, Text:="PAGE ", PreserveFormatting:=True
- .TypeText Text:=" 页 共 "
- .Fields.Add Range:=.Range, Type:=wdFieldEmpty, Text:="NUMPAGES ", PreserveFormatting:=True
- .TypeText Text:=" 页"
- End With
- Loop
- End With
- End With
- End Sub
复制代码 |