PC Review
Forums
Newsgroups
Microsoft Outlook
Microsoft Outlook Program Addins
Programmatically invoking menu items?
Forums
Newsgroups
Microsoft Outlook
Microsoft Outlook Program Addins
Programmatically invoking menu items?
![]() |
Programmatically invoking menu items? |
|
|
Thread Tools | Rate Thread |
|
|
#1 |
|
Guest
Posts: n/a
|
Hi all,
I'm developing an Outlook AddIn in C++ using ATL. I've found that I can programmatically invoke the spelling checker on a new email message being composed by using the Find method of _CommandBars to locate the Tools menu control, and then the Spelling... menu item control, and calling Execute() on them in the right order, i.e. hr = spTools->Execute(); hr = spSpelling->Execute(); This works like a charm. Now I need to be able to invoke Tools -> Send/Receive -> Send All of the top level explorer in Outlook 2002. It seems identical to the above case, except that the menu item is two levels deep. However, for some reason this does not work. When I call Execute() on the Send All menu item (having previously called Execute() on Tools and Send/Receive in that order), it returns E_FAIL, and the Send All operation is not performed. Does anyone have an explanation for this? Is there another way? I know I could "invoke" the Send/Receive button on the Standard toolbar, but what I need is "send", not "send and receive". And I am aware of Redemption::IMAPIUtils: eliverNow(), but that only workswith Exchange. Thanks in advance! Best, Martynas |
|
|
|
#2 |
|
Guest
Posts: n/a
|
1. You do not need to travel the menu hierarchy to find a button, use
CommandBars.FindControl instead, it will search all of the child toolbars. 2. Executing a menu item hidden at the time the code runs results in an error, I don't think there are any workarounds. Dmitry Streblechenko (MVP) http://www.dimastr.com/ OutlookSpy - Outlook, CDO and MAPI Developer Tool "Martynas Kunigelis" <kunigelis@centras.lt> wrote in message news:##WAVdqSDHA.2148@TK2MSFTNGP12.phx.gbl... > Hi all, > > I'm developing an Outlook AddIn in C++ using ATL. I've found that I can > programmatically invoke the spelling checker on a new email message being > composed by using the Find method of _CommandBars to locate the Tools menu > control, and then the Spelling... menu item control, and calling Execute() > on them in the right order, i.e. > > hr = spTools->Execute(); > hr = spSpelling->Execute(); > > This works like a charm. > > Now I need to be able to invoke Tools -> Send/Receive -> Send All of the top > level explorer in Outlook 2002. It seems identical to the above case, except > that the menu item is two levels deep. > > However, for some reason this does not work. When I call Execute() on the > Send All menu item (having previously called Execute() on Tools and > Send/Receive in that order), it returns E_FAIL, and the Send All operation > is not performed. > > Does anyone have an explanation for this? Is there another way? I know I > could "invoke" the Send/Receive button on the Standard toolbar, but what I > need is "send", not "send and receive". > > And I am aware of Redemption::IMAPIUtils: eliverNow(), but that onlyworks > with Exchange. > > Thanks in advance! > > Best, > Martynas > |
|
|
|
#3 |
|
Guest
Posts: n/a
|
Hi Dmitry,
You misunderstood, I don't travel the hierarchy to find the menu items, I use just the technique you've described. However, when I have retrieved all the items in the "chain", I "travel" the hierarchy calling Execute() on them, so that the bottom level menu actually gets displayed. This is why I'm surprised that spSendAll->Execute() fails -- the "Send / Receive" menu is certainly visible at the moment, and "Send All" is enabled. Again, this technique works fine for invoking Inspector's Tools ->Spelling... menu item, but fails for Explorer's Tools->Send / Receive->Send All for some reason. The only difference I can see is that in the latter case the menu item is two levels deep... Any ideas? Thanks for your answer! Best, Martynas "Dmitry Streblechenko" <dmitry@dimastr.com> wrote in message news:u7gTtcxSDHA.2260@TK2MSFTNGP12.phx.gbl... > 1. You do not need to travel the menu hierarchy to find a button, use > CommandBars.FindControl instead, it will search all of the child toolbars. > 2. Executing a menu item hidden at the time the code runs results in an > error, I don't think there are any workarounds. > > Dmitry Streblechenko (MVP) > http://www.dimastr.com/ > OutlookSpy - Outlook, CDO > and MAPI Developer Tool > > |
|
|
|
#4 |
|
Guest
Posts: n/a
|
Could you elaborate on adding "do events"? How do I do this?
"Dmitry Streblechenko" <dmitry@dimastr.com> wrote in message news:u3BSt%237SDHA.212@TK2MSFTNGP10.phx.gbl... > I don't know, sorry. I guess a menu items needs to be displayed for some > time before it becomes useable. Try to add "do events" before you call > CommandBarButton.Execute. > > Dmitry Streblechenko (MVP) > http://www.dimastr.com/ > OutlookSpy - Outlook, CDO > and MAPI Developer Tool > > |
|
|
|
#5 |
|
Guest
Posts: n/a
|
I mean running the Windows message loop: in C++/Delphi
(GetMessage/TranslateMessage/DispatchMessage) in VB - "Do Events" (or whatever it is called). Dmitry Streblechenko (MVP) http://www.dimastr.com/ OutlookSpy - Outlook, CDO and MAPI Developer Tool "Martynas Kunigelis" <kunigelis@centras.lt> wrote in message news:uInEKkFTDHA.2264@TK2MSFTNGP11.phx.gbl... > Could you elaborate on adding "do events"? How do I do this? > > "Dmitry Streblechenko" <dmitry@dimastr.com> wrote in message > news:u3BSt%237SDHA.212@TK2MSFTNGP10.phx.gbl... > > I don't know, sorry. I guess a menu items needs to be displayed for some > > time before it becomes useable. Try to add "do events" before you call > > CommandBarButton.Execute. > > > > Dmitry Streblechenko (MVP) > > http://www.dimastr.com/ > > OutlookSpy - Outlook, CDO > > and MAPI Developer Tool > > > > > |
|
![]() |
|
| Thread Tools | |
| Rate This Thread | |
|
|

Main Page 
eliverNow(), but that only works
