Answered by:
SpellingAndGrammar window does not stay

Question
-
Hello
I am calling SpellingAndGrammar in my Add-In (VSTO - Outlook AddIn) as below.
---------
Dim
offCBs As Office.CommandBars = Me.Application.ActiveInspector().CommandBars
offCBs.GetType().InvokeMember(
"ExecuteMso", System.Reflection.BindingFlags.InvokeMethod, Nothing, offCBs, New Object() {"SpellingAndGrammar"})----------
Problem is that it won't stay until i complete the spell check. Spell Check window shows up, automatically closes and next line of code is executed.
Any idea how i can make the spell check stay until i complete it?
Thanks
Thursday, January 5, 2012 2:03 PM
Answers
-
Hello,
Instead of invoking the command, add a reference to Word's interop and invoke the method:
Imports Word = Microsoft.Office.Interop.Word '... CType(Me.Appication.ActiveInspector.WordEditor, Word.Document).CheckSpeclling(...)
The code line above uses the fact that Word is the email editor in Outlook 2007-2010.Does it help?
Regards from Belarus (GMT + 3),
Andrei Smolin
Add-in Express Team LeaderThursday, January 5, 2012 8:05 PM
All replies
-
maybe there are no error to correct so it closes? When are you invoking that code?Thursday, January 5, 2012 2:36 PM
-
No there are errors to correct. I can see Spell Checket showing words to be corrected but it wont stay.
I have a command bar button (named - "Imaging") added in outlook. When composing a new email, you click on this Command Bar button - Imaging. What it does is to send the email and invoke a windows form which will help the user to take the sent email and put it in the image database. Before sending the email i am calling ExecuteMso on SpellingAndGrammar as the user wants to have spell check invoked. (Option to spell check before sending the email is enabled in Outlook.)
Thanks
Thursday, January 5, 2012 2:50 PM -
Hello,
Instead of invoking the command, add a reference to Word's interop and invoke the method:
Imports Word = Microsoft.Office.Interop.Word '... CType(Me.Appication.ActiveInspector.WordEditor, Word.Document).CheckSpeclling(...)
The code line above uses the fact that Word is the email editor in Outlook 2007-2010.Does it help?
Regards from Belarus (GMT + 3),
Andrei Smolin
Add-in Express Team LeaderThursday, January 5, 2012 8:05 PM -
Hi Andrei
Word is not the default editor in my outlook. In order for your code to work, should i make the default editor as word in Outlook/
Thanks
Friday, January 6, 2012 1:05 PM -
> Word is not the default editor in my outlook. In order for your code to work, should i make the default editor as word in Outlook/
Sorry? Are you using Outlook 2000-2003? If you use Outlook 2007-2010, then in what way the code doesn't work? Exceptions? Inspector.WordEditor returns Nothing (null in C#)?
Regards from Belarus (GMT + 3),
Andrei Smolin
Add-in Express Team LeaderFriday, January 6, 2012 1:19 PM -
Hi V2011,
Thanks for posting in the MSDN Forum.
Would you please clarify the questions that Andrei asked? I think that is important for further research.
Have a good day,
Tom
Tom Xu [MSFT]
MSDN Community Support | Feedback to us
Tuesday, January 10, 2012 8:55 AM -
Hello Andrei and Tom
I apologize for not posting the reply right away. Everything is working fine now. I am able to invoke the SpellChecker as suggested by Andrei. I got this working last week.
Thanks a lot for the Help Andrei.
Thursday, January 19, 2012 8:45 PM