Automate Spell Check With Outlook XP?

B

Brian McCullough

Hello,

I am looking to automate the Spell Check functionality through a COM Addin
in Outlook XP.

Is this possible? Can anyone point me to a good article/link/site that
might explain this?

TIA

-Brian
 
K

Ken Slovak - [MVP - Outlook]

Outlook spell checking can't be automated. You can use a 3rd party spell
check library to do that but of course it wouldn't have the exclusions and
settings set for the Outlook spell checker. An alternative would be to
automate Word and pass the text you want checked to a Word document object
and then calling on Word to spell and/or grammar check the text.
 
B

Brian McCullough

What about something like this:

Private Sub ExecuteSpellCheck()
Dim ctlSpellCheck As CommandBarControl
Dim cbrMenuBar As CommandBar

Set cbrMenuBar = m_objInsp.CommandBars("Standard")

Dim ctlTmp As CommandBarControl
For Each ctlTmp In cbrMenuBar.Controls
If ctlTmp.Type = msoControlButton Then
If ctlTmp.Caption = "&Spelling and Grammar..." Then
Set ctlSpellCheck = ctlTmp
Exit For
End If
End If
Next
ctlSpellCheck.Execute

End Sub


Now what if I wanted to execute the spell check using the above and then
perform some additional processing such as change the Subject line and send
the message, but I would only want the additional processing to occur after
the spell check?? So the code that called to this ExecuteSpellCheck method
might look like so:

Sub MyCommandButton_Click

ExecuteSpellCheck

'do more processing after spell check has completed...
objInsp.CurrentItem.Subject = "A Custom Subject"
objInsp.CurrentItem.Send
objInsp.Close olDiscard

End Sub





Thanks!
 
K

Ken Slovak - [MVP - Outlook]

That code depends on:
1) the email being a WordMail email
2) the email not being in Outlook 2007
3) the user running an English language version of Outlook and Word
4) access to the Word Standard toolbar from the email

The best way to find a control in a toolbar is to use the
CommandBar.FindControl method with the ID of the built-in control you are
looking for. That would be language independent. It would not help if the
user customized the toolbar.

If I were depending on WordMail being used I'd use the Word object model to
check the text. It doesn't depend on version or customizations or language
dependencies. The Inspector.WordEditor object is a Word.Document object.
Given that you can use the Document.CheckSpelling method. You could also
call the Document.CheckGrammar method if you wanted to check the grammar in
the text.

If you are sending the email why are you then closing it after sending it?
 
B

Brian McCullough

Ken,

Even if I could automate the spell check, is there a way to do this
syncrhonously? For example, here is what I would need to do:

1. Perform Spell check
2. If spell check was not cancelled:
A. Change the Subject line
B. Send the message

Whenever I try to perform the spell check, my code continues to execute
behind the scenes and attempts to send the message before the spell check is
done and therefore doesn't take into account if the user has cancelled the
sending of the message.

-Brian
 
K

Ken Slovak - [MVP - Outlook]

You need to set a flag when the spell check finishes and loop until that
flag is set or some timeout period passes to get some kind of synchronous
process.
 

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