We help IT Professionals succeed at work.

Outlook 2003 macro to add a toolbar button to edit a selected message

To edit a selected message, I have to double-click the messages, then click on 'Edit', then click on 'Edit message'.  I would like to add a button on my Outlook 2003 toolbar that when clicked will save me doing the above.
Comment
Watch Question

Top Expert 2011

Commented:
where would you like the button/menu?

Easy for example is:

Insert the following snippet code into a normal code module:

1. Right click a blank area of the toolbar
2. Select Toolbars | New | NAme it | Drag it onto the menu area
3. Select Customise | Commands | MAcros
4. Navigate to editMailItem and drag to your new toolbar.
5. Right click on the button to change properties
6. Close customise window

Presto.
Chris
Sub editMailItem()
    If Application.ActiveExplorer.Selection.count <> 1 Then Exit Sub
    With Application.ActiveExplorer.Selection(1)
        .Display
    End With
End Sub

Open in new window

Author

Commented:
Thank you Chris.
The macro you suggested opens the selected email but to edit the message I still have to select 'Edit' then 'Edit message'.  Is there a way adding this function to the macro?
Top Expert 2011
Commented:
True True - sorry.

Not using 2003 at the moment so try:

Chris
Sub displayMailItem()
    If Application.ActiveExplorer.Selection.count <> 1 Then Exit Sub
    With Application.ActiveExplorer.Selection(1)
        .Display
        SendKeys "%{e}"
        SendKeys "%{e}"
    End With
End Sub

Open in new window

Top Expert 2011
Commented:
Tried it on 2003, no go.

Tried this one looks fine.

Chris
Sub displayMailItem()
Dim objInspect As Object
Dim mnuEditMessage As Office.CommandBarButton

    If Application.ActiveExplorer.Selection.count <> 1 Then Exit Sub
    Set objInspect = Application.ActiveExplorer.Selection(1).GetInspector
    objInspect.Display
    Set mnuEditMessage = objInspect.CommandBars.findControl(, 5604)
    mnuEditMessage.Execute

End Sub

Open in new window

Author

Commented:
Chris,

I changed the second SendKeys in your previous solution to SendKeys "{e}" and it worked.

Many thanks.
Top Expert 2011

Commented:
I did that on the 2003 machine and it didn't work for me but now you have two solutions :o)

CHris