Richard U
Active Member
- Joined
- Feb 14, 2006
- Messages
- 406
- Office Version
- 365
- 2016
- 2010
- 2007
- Platform
- Windows
I've used the commandbar to create and remove buttons....
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)
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)