使用“宏”删除WORD中的重复字
有如下文档,要求删除氇筐塘瓠里面的重复字符。
二、建立宏。主要代码如下
Dim str As String
Dim bstr As String
Dim cf As String
Dim i As Long
Selection.WholeStory
str = Selection.Text
For i = 1 To Len(str)
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = Mid(str, i, 1)
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = True
.MatchWholeWord = False
.MatchByte = True
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
If Selection.Find.Found = True Then
Selection.Find.Execute Replace:=wdReplaceAll
Selection.Text = Mid(str, i, 1)
cf = cf & Mid(str, i, 1)
End If
Next i
MsgBox cf
三、运行宏
四、结果如下
声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
阅读量:46
阅读量:34
阅读量:72
阅读量:38
阅读量:62