Microsoft KB Archive/67899

Macro WHILE Found Loop Appears Not to Work

PSS ID Number: Q67899 Article last modified on 11-02-1994

5.50

MS-DOS

= SUMMARY =

The macro example (Example 1) found on page 483 of the “Using Microsoft Word” manual has some limitations that are not stated within the text. The “PromptMode” that is set within the Word macro will greatly affect how the macro loop will execute. If the “PromptMode” is not explicitly set, Word will default to “macro”. With the PromptMode set to “macro”, the Example 1 macro on page 483 will not execute properly as shown (see the PromptMode=“Macro” sample below for the correction).

= MORE INFORMATION =

Macro Example 1 on page 483 of the “Using Microsoft Word” manual is listed below. Note that the “chevron” signs (<< >>) are depicted as double > or < symbols. The chevrons can be created with the CTRL key in combination with the appropriate square bracket key (that is, CTRL+]).

Example 1
 <>  <>    <>

The above macro example will execute three different ways, depending on the PromptMode currently in effect.

For example:

PromptMode=“User” —————–

With PromptMode set to “user”, the macro will prompt the user with a “continue searching from top of document” message when the loop reaches the bottom of the document. The message will appear even if  was executed immediately before the search was executed in the macro. The user needs to respond to the continue searching from the top of the document message before processing can continue.

PromptMode=“Ignore” ——————-

Because the default for the “continue from top of document” dialog box is “yes”, the macro will always restart the search, causing it to loop endlessly. The “ignore” PromptMode should never be used with this type of WHILE Found loop.

PromptMode=“Macro” ——————

The “macro” PromptMode is probably the best option for the WHILE Found loop, but it requires a modification to the example macro listed above. Upon successful completion of the loop, the dialog box with the continue message will appear. The macro should respond “No” to the message by placing the character “n” immediately after the ENDWHILE statement. If a “n” is not placed after the ENDWHILE statement, Word will attempt to accept the following characters as a response to the dialog box (if the following characters are not a “y” or an “n”, Word will beep with each invalid character).

KBCategory: kbother kbmacro KBSubcategory: Additional reference words:

=
================================================================ Copyright Microsoft Corporation 1994.