Consulting

Results 1 to 2 of 2

Thread: Dynamically add Toolbar with Buttons

  1. #1

    Exclamation Dynamically add Toolbar with Buttons

    Hi

    Can someone share code sample on how to check for a Toolbar and accordingly add a custom toolbar with buttons.

    Thanks in advance

  2. #2
    Site Admin
    Urban Myth
    VBAX Guru
    Joined
    May 2004
    Location
    Oregon, United States
    Posts
    4,940
    Location
    Hi there,

    You might be able to use something like this, although I'm not sure what version you're working with...

    [vba]Private Sub Application_Startup()
    Dim olApp As Application, NS As NameSpace, olFld As Folder
    Dim cbMenu As CommandBar, cmbNew As CommandBarButton
    On Error Resume Next
    Set olApp = Outlook.Application
    Set NS = olApp.GetNamespace("MAPI")
    Set olFld = NS.GetDefaultFolder(olFolderInbox)
    olApp.ActiveExplorer.CurrentFolder = olFld
    Set cbMenu = ActiveExplorer.CommandBars("Menu Bar")
    'Menu Bar
    'Standard
    'Advanced
    'Web
    On Error Resume Next
    Set cmbNew = cbMenu.Controls("Caption").Delete
    On Error Resume Next
    Set cmbNew = cbMenu.Controls.Add(msoControlButton)
    With cmbNew
    .Caption = "Caption"
    .OnAction = "macroName"
    .TooltipText = "toolTip"
    .FaceId = "FaceId"
    .Style = msoButtonIconAndCaption
    .BeginGroup = True
    End With
    End Sub[/vba]

    HTH

Posting Permissions

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