Adding Item to the Email Actions Menu

  • Thread starter Thread starter StudioTwo
  • Start date Start date
S

StudioTwo

Hello,
Here is bit of code i used to associate a macro to the "Action" menu
within Outlook. However, I really need the option to be avialable on
the Action menu of the actual email (when I have the message open).
Could anyone advise me how I can reference that menu?

Sub AddSaveToContractMenuItem()
'Add The SaveToContract Macro To The File Menu.

Dim objCBs As CommandBars, objCBCs As CommandBarControls
Dim objCBP As CommandBarPopup, objCBB As CommandBarButton
Dim intX As Integer

Set objCBs = Application.ActiveExplorer.CommandBars
Set objCBP = objCBs.FindControl(, 30131) 'GET THE Mail Actions
MENU
Set objCBCs = objCBP.Controls
Set objCBB = objCBCs.Add
objCBB.Caption = "Save To Contract"
objCBB.OnAction = "RunSaveToContractForm"

End Sub

TIA
Stephen
 
You need to return the CommandBars collection from the Inspector object. The
Explorer object is for the main Outlook windows, while Inspectors are for
individual items (e-mails, Tasks, Contacts, etc.).
 
Eric,
I am really struggling on this one.
Any chance you could give me a pointer?

TIA
Stephen
 
Ah, I see. There needs to be an open message.

Thank you so much,
Stephen


Eric Legault said:
Sure Stephen. Note the changes I made to your code to retrieve the
CommandBars collection from the Inspector object instead of the Explorer
object.

Sub AddSaveToContractMenuItem()
'Add The SaveToContract Macro To The File Menu.

Dim objCBs As CommandBars, objCBCs As CommandBarControls
Dim objCBP As CommandBarPopup, objCBB As CommandBarButton
Dim intX As Integer

'Need an open e-mail message; you could also create a temporary one here
and
'discard it when the menu item has been added

If Application.ActiveInspector Is Nothing Then Exit Sub

'The CommandBars collection is different for e-mails (an Inspector
object) compared
'to the CommandBars exposed by the main Outlook window (an Explorer
object)
Set objCBs = Application.ActiveInspector.CommandBars
Set objCBP = objCBs.FindControl(, 30131) 'GET THE Mail Actions MENU
Set objCBCs = objCBP.Controls
Set objCBB = objCBCs.Add
objCBB.Caption = "Save To Contract"
objCBB.OnAction = "RunSaveToContractForm"
End Sub

--
Eric Legault - B.A, MCP, MCSD, Outlook MVP
--------------------------------------------------
{Private e-mails ignored}
Job: http://www.imaginets.com
Blog: http://blogs.officezealot.com/legault/


StudioTwo said:
Eric,
I am really struggling on this one.
Any chance you could give me a pointer?

TIA
Stephen

"Eric Legault [MVP - Outlook]" <[email protected]> wrote in
message news: said:
You need to return the CommandBars collection from the Inspector object. The
Explorer object is for the main Outlook windows, while Inspectors are for
individual items (e-mails, Tasks, Contacts, etc.).
 
Back
Top