|
[目标]数字前后批量添加空格和下划线:
They were at 65 and 99887.
They 4 saw 3 difference between
the 32 choices. 995 of 21, they were on cloud 9.
*方法1——【查找和替换】:
【查找内容】[0-9]{1,}
【替换为】^32^&^32
【使用通配符】√(勾选)
*方法2——VBA宏代码:(Test-OK)
*******************************************
Sub 数字前后批量添加空格和下划线()
Dim r As Range, s As Range
If Selection.Type = wdSelectionIP Then
With ActiveDocument.Content.Find
.Replacement.Font.Underline = wdUnderlineSingle
.Execute "[0-9]{1,}", , , 1, , , , 1, , "^32^&^32", 2
End With
Else
Set r = Selection.Range
Set s = Selection.Range
r.Find.ClearFormatting
Do While r.Find.Execute("[0-9]{1,}", , , 1, , , , , 1, "", 0)
r.Font.Underline = wdUnderlineSingle
r = Chr(32) & r & Chr(32)
r.Collapse 0
r.SetRange Start:=r.Start, End:=s.End
Loop
End If
End Sub |
|