objSendButton.Execute?

B

Brian McCullough

Hello,

In a VB6 COM Add In for Outlook (XP), can you automate the pressing of the
Send button on a MailItem's Inspector? I am trying, but keep getting the
following error message:

-2147467259: Method '~' of object '~' failed

for example:

Dim objSendBtn As CommandBarControl
Set objSendBtn = m_objInsp.CommandBars.FindControl(ID:=2)

'do some simple processing here, such as change the subject line

objSendBtn.Execute
 
K

Ken Slovak - [MVP - Outlook]

Are you getting the correct button? Why not just use item.Send?
 
B

Brian McCullough

I am getting the correct button. I display a message box displaying the ID
and caption of the button for debugging purposes.

Item.Send does not take into account the Spell check settings...I am trying
to see if I can just mimic the Send Button functionality which does perform
Spell Check if the "Always check spelling before sending" option is selected
(Tools > Options > Spelling tab).

Is the Send button's Execute method blocked by the security updates?

-Brian
 
B

Brian McCullough

Hello,

OK, looks like automating the Send button in Outlook XP does not work
because the the Security Updates: http://support.microsoft.com/kb/262701

I posted about this previously
(microsoft.public.office.developer.com.add_ins: "Automate Spell Check With
Outlook XP?"), but not sure I had a complete understanding of the
requirements before. Here we go...

In general, Word is NOT being used as the email editor, but some users may
be using it as their editor. I am looking for a way to do the following:

1. If the user has the "Always check spelling before sending" option
selected in Outlook:
A. Perform Spell check (using which ever spell check is appropriate for
the client - Word or Outlook)
2. If spell check didn't run (because the "Always check spelling before
sending" is not selected)
OR the spell check did run and it was not cancelled and it completed:
A. Change the Subject line
B. Send the message

This sounds like such a simple thing, but I am not seeing a way to
accomplish this.

Is it possible to determine the "Always check spelling before sending"
value?

It seems that Outlook's Spell Checking is not available to be automated,
(short of calling the Execute method on the "Spelling" command). That being
said, are there any drawbacks to instantiating a Word Application/Document
and passing letting it handle the Spell Checking? Is this spell check call
to Word synchronous?

Thanks again!!!
 
K

Ken Slovak - [MVP - Outlook]

Word.Document.CheckSpelling() is a sub, so it's not going to wait for spell
check completion as far as I know. I'm not sure it even can be determined
that the spell check is finished. according to the Word help if a spelling
error is detected the Spelling and Grammar dialog is displayed. So your code
would continue after calling spell check and wouldn't know it was finished
or canceled or whatever.

You might just have to use a 3rd party spelling control of some kind if you
want additional control over the process.

Look at HKCU\Software\Microsoft\Office\11.0\Outlook\Options\Spelling\Check
(change 11.0 to your version, 2002 would be 10.0). If Check (REG_DWORD) = 0
no spell check, if = 1 then spell check.
 
B

Brian McCullough

Are there any other drawbacks to using the Word spellcheck?

For example, do they use different dictionaries? Are there any other
gotchas?

Thanks again, Ken!!
 
B

Brian McCullough

Can you recommend any third party spell checking tools for use with Outlook?
 
K

Ken Slovak - [MVP - Outlook]

If the Outlook editor is being used the Word spell checker won't use the
same dictionaries of course. You can specify custom dictionaries to use with
Word spell check, but to tell the truth I haven't done anything that
required any spell checking so I'm not all that familiar with all the
possible scenarios.
 

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