skip to content »

centr-geoteh.ru

Word vba screen updating

(Microsoft Word is the most popular word processing software in the world.) This tip (749) applies to Microsoft Word 97, 2000, 2002, and 2003.

word vba screen updating-73word vba screen updating-35word vba screen updating-10word vba screen updating-65

' -------------------------------------------------------------------------------- ' You are free to use this code within your own applications, add-ins, ' documents etc but you are expressly forbidden from selling or ' otherwise distributing this source code without prior consent.You must set the Screen Updating property to True when the procedure finishes or when it stops after an error. This example turns off screen updating and then adds a new document. I've got a word 2013 macro which is taking quite some time to finish.The macro is reformatting the document and the Screen keeps updating while the macro is running, which I guess is where word spends most of it's time.When screen updating is turned off, toolbars remain visible and Word still allows the procedure to display or retrieve information using status bar prompts, input boxes, dialog boxes, and message boxes.

You can increase the speed of some procedures by keeping screen updating turned off. Insert Paragraph After End With If x Mod 50 = 0 Then Active Document.

Five hundred lines of text are added to the document.

At every fiftieth line, the macro selects the line and refreshes the screen.

While Excel will set this back to True whenever focus is passed back to Excel (your macro finishes) in most cases, it pays to play it safe and include the code at the end.

You may even find in some cases that Screen Updating is set back to true before your recorded macro completes.

Thus, the main body of your macro can do its work behind the scenes without the necessity of stopping to update the screen.