Microsoft KB Archive/82251

{|
 * width="100%"|

Corruption with Macro Run on ToolsGrammar and ToolsSpelling

 * }

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 &quot;ToolsSpelling&quot; or ToolsMacro &quot;ToolsGrammar.&quot;

Steps to Reproduce Problem
 In a new document, type This is an sentence..  Create and run the following macro:   Sub MAIN SendKeys &quot;%c&quot; ToolsMacro .Name = &quot;ToolsGrammar&quot;, .Run, .Show = 0 Insert &quot;yo&quot; End Sub 

The document becomes corrupt. The text reads &quot;Thisis,&quot; 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 &quot;an&quot; should be replaced with &quot;a,&quot; and the selection should not be altered. The &quot;yo&quot; should not be inserted until after the dialog box has been exited. The problem is that &quot;yo&quot; 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

Issue type :

Technology :