How do i remove button from "Add-Ins"

Posted on 2011-04-29
Last Modified: 2012-05-11
I have on "add-Ins" menu button "My button" (see printscreen)
i would like to remove it from there

what should i have to change it the below code to remove it?


Public Sub Workbook_Open()

MacroName1 = "ThisWorkbook.RunComparingInventory"

    Set cbarMenu = Application.CommandBars

    ' First, look for button on the toolbar already.
    For Each cctlControl In cbarMenu("Standard").Controls
        With cctlControl
        If .Caption = "my button" Then
        End If
        If .Caption = "RunComparingInventory" Then
        End If
        End With
    Next cctlControl

    Set cctlControl1 = Application.CommandBars("Standard").Controls.Add(Type:=msoControlButton, Before:=1)
    With cctlControl1
        .Style = msoButtonCaption
        .Caption = "RunComparingInventory"
        .OnAction = MacroName1
        .TooltipText = "Run Comparing Inventory"
        .Enabled = True
    End With
End Sub

Open in new window

Question by:gvilbis
    LVL 41

    Accepted Solution

    I'm not sure how you created "my button" so unsure as to what level its at in the commandbar menu structure.

    If its at the top level, then you should be searching Application.CommandBars for "my button" then delete.

    If its subordinate to "Standard" as you have coded, that should work.

    Here's a test code routine that enumerates all command bars, searching for "Standard", then enumerates through controls of "Standard" to find "my button"...

    If this doesn't work, then your "my button" control may not be subordinate to "Standard".

    Take a look.  

    you could provide me the code you use to create the "my button" control then I could zoom in on the problem, more readily...

    See the code:
    Sub test()
    Dim myCmdBar As CommandBar, myControl As CommandBarControl
        For Each myCmdBar In Application.CommandBars
            If myCmdBar.Name = "Standard" Then
                For Each myControl In myCmdBar
                    If myControl = "my button" Then
                    End If
                Next myControl
            End If
        Next myCmdBar
    End Sub

    Open in new window


    LVL 7

    Assisted Solution

    by:philip m o'brien
    I suggest that you run the following code, then in the list created look for "my button" and check that the caption name is what you think i.e. ensure it has no leading/trailing spaces etc.
    If you find it is different then the code provided by Dave will work once amended for the actual caption.
    Sub cbarIndex()
    Dim cbar As Office.CommandBar
    Dim cbc As CommandBarControl, cbtn As CommandBarButton
    Dim r As Integer
    Dim c As Integer
    r = 3
    c = 3
    Application.ScreenUpdating = False
    On Error Resume Next
    For Each cbar In Application.CommandBars
    Cells(r, c) = cbar.Name
    Cells(r, c + 1) = cbar.Type 'msoBarTypeMenuBar,msoBarTypePopup, msoBarTypePopup
    r = r + 1
    For Each cbc In cbar.Controls
    Cells(r, c + 1) = cbc.Caption
    Cells(r, c + 2) = cbc.ID
    Cells(r, c + 3) = cbc.BuiltIn
    Cells(r, c + 4) = cbc.OnAction
    If cbc.Type = msoControlButton And Not cbc.BuiltIn Then
    Set cbtn = cbc
    Selection.Top = Cells(r, c + 5).Top
    Selection.Left = Cells(r, c + 5).Left
    End If
    r = r + 1
    r = r + 1
    Application.ScreenUpdating = True
    End Sub

    Open in new window


    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    Suggested Solutions

    This is pretty cool.  The purpose of this VB Script is to help you document where JAR (Java ARchive) files and specifically java class files are located so that you can address issues seen with a client or that you can speak intelligently with a dev…
    Improved? Move/Copy Add-in Replacement - How to avoid the annoying, “A formula or sheet you want to move or copy contains the name XXX, which already exists on the destination worksheet.” David Miller (dlmille)  It was one of those days… I wa…
    The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
    This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

    731 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now