Consulting

Results 1 to 2 of 2

Thread: Standard toolbar changes when email is opened

  1. #1
    VBAX Regular
    Joined
    Dec 2006
    Posts
    71
    Location

    Standard toolbar changes when email is opened

    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.

  2. #2
    VBAX Expert JP2112's Avatar
    Joined
    Oct 2008
    Location
    Astoria, NY
    Posts
    590
    Location
    Looks like code you got from 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.

    Quote Originally Posted by g8r777
    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.
    Regards,
    JP

    Read the FAQ
    Getting free help on the web
    My website
    Please use [vba][/vba] tags when posting code

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •