一篇文章里面含有"【"和"】",我要查找这两个字符之间的东西,然后把他们的字体设置成“Arial”。我想用VBA来实现,有位大侠跟我说了下面的代码。Sub replacestr()
Do
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "\[*\]"
.Replacement.Text = ""
.forward = True
.wrap = wdFindContinue
.format = True
.matchcase = False
.matchwholeword = False
.MatchByte = False
.matchallwordforms = False
.matchsoundslike = False
.matchwildcards = True
End With
Selection.Find.Execute
If Selection.Font.Name = "Arial" Then
Exit Do
End If
Selection.Font.Name = "Arial"
Loop就会出现死循环的情况!因为如果查找的是“【able】”,两边的“【”和“】”不能设置为“Arial”,只有able被设置为“Arial”。
因此我想请问可否让循环只能查找文档一次就自动停止或者有其他方法可以解决这个问题
Do
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "\[*\]"
.Replacement.Text = ""
.forward = True
.wrap = wdFindContinue
.format = True
.matchcase = False
.matchwholeword = False
.MatchByte = False
.matchallwordforms = False
.matchsoundslike = False
.matchwildcards = True
End With
Selection.Find.Execute
If Selection.Font.Name = "Arial" Then
Exit Do
End If
Selection.Font.Name = "Arial"
Loop就会出现死循环的情况!因为如果查找的是“【able】”,两边的“【”和“】”不能设置为“Arial”,只有able被设置为“Arial”。
因此我想请问可否让循环只能查找文档一次就自动停止或者有其他方法可以解决这个问题
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货