View Single Post
 
Old 06-20-2017, 03:17 PM
Tye30 Tye30 is offline Windows 7 32bit Office 2010 32bit
Novice
 
Join Date: Apr 2017
Posts: 7
Tye30 is on a distinguished road
Default Ugraded to Word 2013 Macro not performing

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
Attached Files
File Type: docx Test_Format.docx (175.1 KB, 28 views)

Last edited by Tye30; 06-21-2017 at 06:25 AM. Reason: Add attachment
Reply With Quote