Corruption with Macro Run on ToolsGrammar and ToolsSpelling

Last reviewed: February 5, 1998
Article ID: Q82251
The information in this article applies to:
  • Microsoft Word for Windows versions 2.0, 2.0a, 2.0a-CD, 2.0b, 2.0c, 6.0, 6.0a, 6.0c

SUMMARY

If you run a macro that calls a modeless dialog box such as ToolsSpelling or ToolsGrammar in Microsoft Word for Windows unexpected results occur if you use ToolsMacro to run the command rather than calling the command directly.

MORE INFORMATION

A modeless dialog box is one that you can activate and switch away from by clicking another active window. For example, you can click your document to switch away from the dialog box. The Spelling and Grammar commands have this type of dialog box.

A modal dialog box is a one that requires you to choose the OK or Cancel button to close the dialog box before you can switch to another action, window, or dialog box.

WORKAROUND

To avoid any unexpected results when calling a modeless dialog box, use the command directly. In a macro, use the ToolsSpelling and ToolsGrammar commands rather than ToolsMacro "ToolsSpelling" or ToolsMacro "ToolsGrammar."

Steps to Reproduce Problem

  1. In a new document, type "This is an sentence." (without the quotation marks).

  2. Create and run the following macro:

       Sub MAIN
       SendKeys "%c"
       ToolsMacro .Name = "ToolsGrammar", .Run, .Show = 0
       Insert "yo"
       End Sub
    
    
The document becomes corrupt. The text reads "Thisis," but the cursor cannot go past the second letter. You cannot select the entire document.

Note: This behavior occur on the first try.

It is expected that the word "an" should be replaced with "a," and the selection should not be altered. The "yo" should not be inserted until after the dialog box has been exited. The problem is that "yo" is inserted underneath the dialog box before the change is made, but the dialog box does not lose the focus. This problem occurs with any modeless dialog box.

Any macro that uses ToolsMacro .Run on a modeless dialog box (ToolsSpelling, ToolsGrammar) will experiencee similar problems.


KBCategory: kbmacro
KBSubcategory:
Additional query words: winword2 2.0 2.0a 2.0a-CD word6
winword 2.0b

Keywords : kbproof kbmacro
Version : 2.0 2.0a 2.0a-CD 2.0b 2.0c
Platform : WINDOWS


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: February 5, 1998
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.