Rakesh
06-07-2015, 10:44 AM
Hi Guys,
Like the below example I had a macro with more than hundred of normal find replace and wildcard replace.
It takes 5 to 8 minutes to run.
Is there a way to run the macro faster?
Sub test()
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "aaa"
.Replacement.Text = "bbb"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "ccc"
.Replacement.Text = "dd"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
ActiveDocument.Content.Find.Execute _
FindText:="^13([a-z])", _
MatchWildcards:=True, _
ReplaceWith:=" \1", _
Replace:=wdReplaceAll
ActiveDocument.Content.Find.Execute _
FindText:="( [a-z]@)^13([A-Z])", _
MatchWildcards:=True, _
ReplaceWith:="\1 \2", _
Replace:=wdReplaceAll
End Sub
Thanks,
Rakesh
Like the below example I had a macro with more than hundred of normal find replace and wildcard replace.
It takes 5 to 8 minutes to run.
Is there a way to run the macro faster?
Sub test()
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "aaa"
.Replacement.Text = "bbb"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "ccc"
.Replacement.Text = "dd"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
ActiveDocument.Content.Find.Execute _
FindText:="^13([a-z])", _
MatchWildcards:=True, _
ReplaceWith:=" \1", _
Replace:=wdReplaceAll
ActiveDocument.Content.Find.Execute _
FindText:="( [a-z]@)^13([A-Z])", _
MatchWildcards:=True, _
ReplaceWith:="\1 \2", _
Replace:=wdReplaceAll
End Sub
Thanks,
Rakesh