General discussion

Locked

Screen update and refresh in Word Macros

By dakota99 ·
I am trying to speed up some of my MS Word macros. Sometimes I run them on documents of over 1000 pages. The ScreenUpdate and ScreenRefresh commands were recommended. I tried using them in my display macros, but all it did was make the macros changes not work. Is it possible to use these in a macro that changes display properties? If so where would you use them in the following example:

selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find.Replacement.Font
.ColorIndex = wdBlue
End With
With Selection.Find
.Text = "[0-9]"
.Replacement.Text = "^&"
.Forward = True
.wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = True
.MatchSoundsLike = False
.MatchAllWordForms = False
End With

This conversation is currently closed to new comments.

5 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

Screen update and refresh in Word Macros

by DKlippert In reply to Screen update and refresh ...

Application.ScreenUpdating = False
Would appear at the beginning and

Application.ScreenUpdating = True
Application.ScreenRefresh
is not necessary, except to reassure the user that something is happening.

What are you trying to do with this macro?
^& replaces the target with the contents of the Find what box. I don't see the purpose.

Collapse -

Screen update and refresh in Word Macros

by dakota99 In reply to Screen update and refresh ...

The purpose of the Macro is simply to change the color of the things in the find box. It finds the nos. 0-9 everywhere in the file and replace with a blue 0-9. When a large file is full of numbers, the macro takes forever to complete. I wastold that the ScreenUpdate command would help speed it up. But all it seemed to do was cancel out what this macro did. Is it placement of the command or is that just what the command does. I had the impression that it would wait until all the changes were made in a temp type file and then display it at the end of the macro. Thus speeding things up because it didn't have to keep refreshing the display. True or False?????? If this is not the command to use, do you have any other ideas.

Collapse -

Screen update and refresh in Word Macros

by DKlippert In reply to Screen update and refresh ...

This works fine. The code you displayed, lacked the line:
"Selection.Find.Execute Replace:=wdReplaceAll"

Sub NumFormat()

ScreenUpdating = False
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find.Replacement.Font
.ColorIndex = wdBlue
End With
With Selection.Find
.Text = "[0-9]"
.Replacement.Text = "^&"
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = True
End With
Selection.Find.Execute Replace:=wdReplaceAll
ScreenUpdating = True

End Sub

Collapse -

Screen update and refresh in Word Macros

by dakota99 In reply to Screen update and refresh ...

The answer you gave me was functional. However the commands themselves were not a help in saving any processing time. The screen does not update normally until the macro has run the whole way through. I don't see how it could speed things up for me. Thanks for your quick response.

Collapse -

Screen update and refresh in Word Macros

by dakota99 In reply to Screen update and refresh ...

This question was closed by the author

Back to Web Development Forum
5 total posts (Page 1 of 1)  

Related Discussions

Related Forums