Corruption with Macro Run on ToolsGrammar and ToolsSpelling

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..


  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.

Additional query words: winword2 2.0 word6 winword

Keywords : kbproof
Version : WINDOWS:2.0,2.0a,2.0a-CD,2.0b,2.0c,6.0,6.0a,6.0c
Platform : WINDOWS
Issue type :


Last Reviewed: December 22, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.