Outlook VBA reference Application Form

I need to add a button control to the MailItem form in Outlook.
I need to run vba code from this button.

I have figured out how to add buttons to the main outlook form, but not the mailitem form..

How do I reference that form and add a button control??
Who is Participating?
jimbobmcgeeConnect With a Mentor Commented:
The following will add a toolbar to a programmatically created mailitem

    Sub MyMail()
        Dim oMail As MailItem
        Dim oBar As CommandBar
        Dim oBtn As CommandBarButton
        Set oMail = Application.CreateItem(olMailItem)
        Set oBar = oMail.GetInspector.CommandBars.Add("My Command Bar", , , True)
        Set oBtn = oBar.Controls.Add(, , , , True)
        oBtn.Caption = "My Button"
        oBtn.Picture = LoadPicture("x:\mypath\myvalid16x16image.ico")
        oBtn.OnAction = "myModule.myMacro"
        oBtn.Visible = True
        oBar.Visible = True
        Set oBtn = Nothing
        Set oBar = Nothing
        Set oMail = Nothing
    End Sub

If you want to add to the currently open item, remove

        Set oMail = Application.CreateItem(olMailItem)

and change

        Set oBar = oMail.GetInspector.CommandBars.Add("My Command Bar", , , True)

        Set oBar = ActiveInspector.CommandBars.Add("My Command Bar", , , True)


david_glidewellAuthor Commented:
I need to do this through VBA Code...  I have to replicate this to over 100 PC's.
All Courses

From novice to tech pro — start learning today.