Consulting

Results 1 to 6 of 6

Thread: Applying icon to commad BAR not button (user defined add in)

  1. #1

    Applying icon to commad BAR not button (user defined add in)

    Hello Everyone,

    Is there a way to apply icon to command BAR?

    I found that part of code online:

    Private Sub Workbook_Open()
       ' vbaexpress.com/kb/getarticle.php?kb_id=427#instr
       ' 3/22/2010
       Dim cmbBar As CommandBar
       Dim cmbControl As CommandBarControl
       Set cmbBar = Application.CommandBars("Worksheet Menu Bar")
       If cmbBar.Controls(cmbBar.Controls.count).Caption <> "" Then
          Set cmbControl = cmbBar.Controls.Add(Type:=msoControlButton, Temporary:=True)
       End If
       Set cmbControl = cmbBar.Controls.Add(Type:=msoControlPopup, Temporary:=True) 'adds a menu item
       With cmbControl
           .Caption = "&VBA Setup" 'names the menu item
           With .Controls.Add(Type:=msoControlButton) 'adds a dropdown button to the menu item
               .Caption = "Add-Ins Install" 'adds a description to the menu item
               .OnAction = "ToolsInitDLL.AddinsInstall" 'runs the specified macro
               .FaceId = 220 'assigns an icon to the dropdown
           End With
           With .Controls.Add(Type:=msoControlButton)
               .Caption = "Add-Ins Un-Install"
               .OnAction = "ToolsInitDLL.AddInsUninstall"
               .FaceId = 220
           End With
           With .Controls.Add(Type:=msoControlButton)
               .Caption = "Apply Macro Shortcuts"
               .OnAction = "ToolsInitDLL.ApplyShortCuts"
               .FaceId = 220
           End With
           With .Controls.Add(Type:=msoControlButton)
               .Caption = "VB Library References"
               .OnAction = "ToolsInitDLL.ListObjLibReferences"
               .FaceId = 220
           End With
       End With
    End Sub
    I modified it to my needs, I applied FaceIds of my choosing to all buttons I've created.

    But I'm wondering if there is a way to apply icon to command Bar. Here is where I want my icon to be:

    i.imgur.com/TXrKq3D.png
    I've tried .FaceId but it seems that it doesn't work for command Bars. Any ideas?

  2. #2
    A commandbar does not have an icon. The closest you can get is using the first button.
    Regards,

    Jan Karel Pieterse
    Excel MVP jkp-ads.com

  3. #3
    Knowledge Base Approver VBAX Wizard
    Joined
    Apr 2012
    Posts
    5,646

  4. #4
    >Jan Karel Pieterse, what a shame... but thank you for your help

    >snb, is crossposted not allowed? I thought that vbaexpress and ozgrid are two separate portals/forums

  5. #5
    I suggest that you read this

    http://www.excelguru.ca/content.php?...-cross-posters

    Then post links in each Forum to your posts in other Forums
    Hope that helps.
    Get the free Excel based Toolbar or click here for free examples & Excel Consultancy

    RoyUK

  6. #6
    >royUK, apologies for everyone, thanks for very useful link, won't happen again, promise

Posting Permissions

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