请参考以下代码: Sub ReplSpace()
Dim i As Paragraph, MyStart As Long
Application.ScreenUpdating = False
For Each i In ActiveDocument.Paragraphs
MyStart = i.Range.Start
Range(Start:=MyStart, End:=MyStart).Select
Selection.EndKey Unit:=wdLine, Extend:=wdExtend
With Selection
.Find.ClearFormatting
.Find.Replacement.ClearFormatting
With .Find
.Text = " "
.Replacement.Text = "" '查找空格
.Forward = True
.MatchByte = False '不区分半角全角
End With
.Find.Execute Replace:=wdReplaceAll
End With
Next
Application.ScreenUpdating = True
End Sub
Sub InsertSpace()
Dim i As Paragraph
For Each i In ActiveDocument.Paragraphs
i.Range.InsertBefore " "'注意此处是两个全角空格,请在全角下输入此处.
Next
End Sub
|