Add New Menu items to the Tools Menu in Outlook 2007

G

Guest

Does anyone know how to do this? I have seen code on anding additional Menu,
but not how to add items to existing ones. Thanks in advance!
 
S

Sue Mosher [MVP-Outlook]

CommandBar.Controls.Add is the method you use to add new items to any CommandBar in the Explorer.CommandBars collection.
 
G

Guest

The following is the code I have which is meant to add the item.

Public Sub OnStartupComplete(ByRef custom As System.Array) Implements
Extensibility.IDTExtensibility2.OnStartupComplete
' *** BEGIN CUSTOM CODE. ***
Dim objCommandBars As CommandBars
Dim objCommandBar As CommandBar
Dim objCommandBarControl As CommandBarControl

' Create a menu command on the "Tools" menu.
objCommandBars = applicationObject.CommandBars
objCommandBar = objCommandBars.Item("Tools")

' Make sure menu command doesn't already exist.
For Each objCommandBarControl In objCommandBar.Controls

If objCommandBarControl.Caption = "Slides from Graphics..." Then

objCommandBar.Controls.Item("Slides from
Graphics...").Delete()

End If

Next objCommandBarControl

objCommandBarButton = objCommandBar.Controls.Add(msoControlButton)

With objCommandBarButton
.Caption = "New Slides from Graphics..."
.Style = msoButtonCaption
.Tag = "Slides from Graphics..."
.OnAction = "!<PowerPointAddIn.Connect>"
.Visible = True
End With
' *** END CUSTOM CODE. ***


End Sub

I will investigate using the Explorer object.
 
S

Sue Mosher [MVP-Outlook]

This definitely is your problem:

objCommandBars = applicationObject.CommandBars

Your code should check to see whether an ActiveExplorer object exists and, if it does, use its CommandBars.
--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54
 
G

Guest

I can only see a reference to the ActiveExplorer object in VBA. I don't see a
reference for it in VB.NET and I think this is my problem. Do I use VBA to
add the button to the Tools item or is there a way to use VB.NET?
 
S

Sue Mosher [MVP-Outlook]

If you're building an add-in, you use VB.NET. Did you look at the sample I suggested? Pay attention in particular to the InitHandler procedure.

--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54
 
G

Guest

The Me.ActiveExplorer definately is not available to me in VB.NET 2005. I
have VTSO Office Tools installed. Am I missing a class or something??
 
S

Sue Mosher [MVP-Outlook]

Your original post indicated you were using the IDTExtensibility2 shared add-in architecture. Now, you mention VSTO. The two use completely different means to return an Outlook.Application object, from which all other Outlook objects can be derived. So which are you using?

--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54
 

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