PDA

View Full Version : Standard toolbar changes when email is opened



g8r777
03-31-2010, 01:58 PM
I have used to following code to create custom buttons on the standard toolbar.

Function AddToolbarButton(Caption As String, _
toolTip As String, macroName As String, _
Optional toolbarName As String = "Standard", _
Optional FaceID As Long = 325, Optional buttonTag As String, Optional objIndex As Integer)
Dim objBar As Office.CommandBar
Dim objButton As Office.CommandBarButton

Set objBar = ActiveExplorer.CommandBars(toolbarName)
Set objButton = objBar.Controls.Add(Type:=msoControlButton, Before:=objIndex)

With objButton
.Caption = Caption
.OnAction = macroName
.TooltipText = toolTip
.FaceID = FaceID
.Style = msoButtonIconAndCaption
.BeginGroup = True
.Tag = buttonTag
End With
End Function
Sub AddToolBarButtons()

Dim objBar As Office.CommandBar
Set objBar = ActiveExplorer.CommandBars("Standard")
Set tstButton1 = objBar.FindControl(Tag:="New Secure")
Set tstButton2 = objBar.FindControl(Tag:="Reply Secure")
Set tstButton3 = objBar.FindControl(Tag:="Reply All Secure")
Set tstButton4 = objBar.FindControl(Tag:="Forward Secure")

If tstButton1 Is Nothing Then
Call AddToolbarButton("New Secure", "New Secure", "NewSecure", , "1981", "New Secure", 2)
Else
MsgBox "New Secure Already Exists"
End If

If tstButton2 Is Nothing Then
Call AddToolbarButton("Reply Secure", "Reply Secure", "ReplySecure", , "354", "Reply Secure", 8)
Else
MsgBox "Reply Secure Already Exists"
End If

If tstButton3 Is Nothing Then
Call AddToolbarButton("Reply All Secure", "Reply All Secure", "ReplyAllSecure", , "355", "Reply All Secure", 10)
Else
MsgBox "Reply All Secure Already Exists"
End If

If tstButton4 Is Nothing Then
Call AddToolbarButton("Forward Secure", "Forward Secure", "ForwardSecure", , "356", "Forward Secure", 12)
Else
MsgBox "Forward Secure Already Exists"
End If

End Sub


My problem is that when I double click and open an email the standard toolbar changes to no longer include these buttons. All I have is the Reply, Reply All, and Forward Buttons.

I would like to have the Reply Secure, Reply All Secure and Forward Secure buttons to appear on the standard toolbar when an email is open.

Any help is appreciated.

JP2112
04-23-2010, 09:45 AM
Looks like code you got from Create Outlook toolbar buttons using VBA (http://www.codeforexcelandoutlook.com/blog/2009/11/create-outlook-toolbar-buttons-using-vba/)?

I ran your code and couldn't duplicate your issue. It added the buttons to the Standard toolbar, and the buttons were still there when I opened an email.

The buttons are added to the Standard toolbar, which is located in the main Outlook explorer window. It won't add any buttons to the email message window, and clicking them won't reply or forward the currently displayed email.

If you want the buttons on the email, change your code from ActiveExplorer to ActiveInspector. Open any email and then run the code. The buttons will be added to the email window and any future emails should also have them.


I have used to following code to create custom buttons on the standard toolbar.

-- snip --

My problem is that when I double click and open an email the standard toolbar changes to no longer include these buttons. All I have is the Reply, Reply All, and Forward Buttons.

I would like to have the Reply Secure, Reply All Secure and Forward Secure buttons to appear on the standard toolbar when an email is open.

Any help is appreciated.