Hiding and unhiding buttons in "add ins" on ribbon

Richard U

Active Member
Joined
Feb 14, 2006
Messages
406
Office Version
  1. 365
  2. 2016
  3. 2010
  4. 2007
Platform
  1. Windows
I've used the commandbar to create and remove buttons....

Code:
Sub AddNewCB()
   Dim myCommandBar As CommandBar, myCommandBarCtl As CommandBarControl
   On Error GoTo AddNewCB_Err
   Set myCommandBar = CommandBars.Add(Name:="MY_LIST", Position:=msoBarFloating, MenuBar:=False, Temporary:=True)
   myCommandBar.Visible = True

   Set myCommandBarCtl = myCommandBar.Controls.Add(Type:=msoControlButton)
   With myCommandBarCtl
      .Style = msoButtonCaption
      .Caption = "Load File  "
      .OnAction = "'LoadFile'"
   End With
   Set myCommandBarCtl = myCommandBar.Controls.Add(Type:=msoControlButton)
   With myCommandBarCtl
      .Style = msoButtonCaption
      .Caption = "Make ABC   "
      .OnAction = "'Make_ABC"
   End With
   Set myCommandBarCtl = myCommandBar.Controls.Add(Type:=msoControlButton)
   With myCommandBarCtl
      .Style = msoButtonCaption
      .Caption = "Make DEF  "
      .OnAction = "'Make_DEF'"
   End With
   Exit Sub

   Set myCommandBarCtl = myCommandBar.Controls.Add(Type:=msoControlButton)
   With myCommandBarCtl
      .Style = msoButtonCaption
      .Caption = "Export file"
      .OnAction = "Export_File"
   End With
   Exit Sub


AddNewCB_Err:
   Debug.Print Err.Number & vbCr & Err.Description
   Exit Sub
End Sub


Sub RemoveToolbar()
    Dim myCommandBar As CommandBar
    For Each myCommandBar In Application.CommandBars
        If myCommandBar.Name = "LOAD_LIST" Then
            myCommandBar.Delete
            Exit For
        End If
    Next
End Sub


What I want to do is hide buttons as they don't apply. I don't want "Export file" to be visible until I make either ABC or DEF, and after I pick ABC or DEF, I want to hide the one that I don't pick.

How can I do this

(I HATE THIS @#$@^**!!! RIBBON)
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top