Microsoft KB Archive/70731

Cannot Run a Macro in the Background in Word for Windows PSS ID Number: Q70731 Article last modified on 07-20-1993

1.00 1.10 1.10a 2.00

WINDOWS

Summary:

There is no command available in WordBasic to run a macro in the background so that you do not see it execute on the screen while in Microsoft Word for Windows. Redrawing the screen slows the speed of a macro. There are a few possible workarounds to control screen updating and to speed up a macro running in Word for Windows.

Workarounds
  Super DocSize 10,10 creates a document window as small as possible and DocMaximize will restore the document window. -or-   DocMove 600,0 will move a document window out of sight while the macro is running. -or-   ViewDraft 1 will enhance the speed of a macro. 

The following are examples of possible DocSize and DocMove routines that will improve macro speed and inhibit the screen from refreshing while the macro is functioning:

  Using DocSize to reduce the window to a minimal size while the macro is running. Sub Main If DocMaximize Then DocRestore Super DocSize 10, 10 FormatCharacter .Points = “24”  MsgBox “Done: Ready to Restore Window”  DocMaximize End Sub *** These lines are only an example; enter information that is consistent with your macro.   Using DocMove to move the active document out of view while the macro is running. Sub MAIN If DocMaximize Then DocMaximize DocMove 600, 0 FormatCharacter .Points = “24”  MsgBox “Done: Ready to Restore Window”  DocMove 0, 0 End Sub *** These lines are only an example; enter information that is consistent with your macro. 

An additional way to enhance the speed of a Word for Windows macro is to run the macro in draft view. This can be accomplished by adding the line “ViewDraft 1” (without the quotation marks) to the top of your macro just below the Sub MAIN line.

For more information, query on the following words:

echo and off and winword Reference(s):

“Word for Windows Technical Reference,” pages 39-40, 103

“Word for Windows and OS/2 Technical Reference,” pages 152-153, 280

Additional reference words: w4wmacro 1.00 1.10 1.10a 2.0 2.00

=
================================================================

Copyright Microsoft Corporation 1993.