Upgraded to Word 2013 from Word 2010 and the time to execute this macro went form 8 seconds to 208 seconds. When I run the code with not using
Code:
Application.ScreenUpdating = False
it actually runs faster at 191 seconds. Is there a setting I need to adjust or is this some kind of bug?
I am a beginner in VBA and I got this code from online
Code:
Dim StartTime As Double
Dim SecondsElapsed As Double
StartTime = Timer
Application.ScreenUpdating = False
Dim oPara As Paragraph
For Each oPara In ActiveDocument.Paragraphs
If InStr(1, oPara.Range.Text, "!Z! !") = 0 Then
oPara.Range.Delete
End If
Next
With ActiveDocument.Range.Find
.Replacement.ClearFormatting
.Text = "!"
.Replacement.Text = "|"
.MatchWildcards = False
.Execute Replace:=wdReplaceAll, Forward:=True, Wrap:=wdFindContinue
End With
Application.ScreenUpdating = True
SecondsElapsed = Round(Timer - StartTime, 2)
MsgBox "This code ran successfully in " & SecondsElapsed & " seconds", vbInformation