How can I detect that spelling checking is active?

A

Alex

My add-in tries to change the formatting of some text when the selection changes.
However, when I invoke the spelling checker, I get an exception on the following line:

range.Font.Animation = Word.WdAnimation.wdAnimationNone;

stating: "Cannot complete the function because the proofing dialog box is active".

Is there a way for me to catch the invocation of the spelling/grammar checker and temporarily disable some functionality to avoid this error?
Alternatively, can I detect that the spelling/grammar checker is active?


Best wishes,
Alex.
 
P

Peter Huang [MSFT]

Hi

Do you mean the dialog with the caption as below
"The spelling and grammar check is complete."
or
The dialog with caption
"Spelling and Grammar: English (U.S.)"

For the first dialog, the dialog is modal, we can not run code when the
dialog is shown.
For the Second one, I can not reproduce the problem.
When the dialog is shown and run the code below
Sub Test()
ThisDocument.Range().Font.Animation = wdAnimationNone
End Sub


Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
A

Alex

Found a temporary solution:

Overriding ToolsConsistency, ToolsProofing, ToolsSpelling, ToolsSpellSelection and ToolsGrammar makes them modal.

That is, macros of the form:

Sub ToolsProofing()
On Error Resume Next
WordBasic.ToolsProofing
End Sub

etc, will prevent my WindowSelectionChange event from running while the spelling-checking takes place.


Best wishes,
Alex.
 
P

Peter Huang [MSFT]

Hi

Thanks for your knowledge sharing, and I am glad that you have resolved the
issue.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top