Hi,
I am trying to setup an add-in of Excel using the below code. its a sample code of only 4 buttons, however I am using more than 30 buttons on this ribbon. The problem I am facing is about the width of the Command bar, which I am not able to wrap on multiple rows, even using the width property of the command bar.
Please help me on this, if I am doing something wrong in this code.
Thanks,
Vitesh
Private Sub Workbook_Open()
Application.ScreenUpdating = False
On Error Resume Next
Dim cbToolBar As CommandBar
Application.CommandBars("RSA Generic Add-in").Delete
Application.CommandBars("Vitesh").Delete
On Error GoTo 0
csToolbarName = "RSA Generic Add-in"
Set cbToolBar = Application.CommandBars.Add(csToolbarName, msoBarFloating, True, True)
With cbToolBar
Set ctButton1 = .Controls.Add(Type:=msoControlButton, ID:=2950)
Set ctButton2 = .Controls.Add(Type:=msoControlButton, ID:=2950)
Set ctButton3 = .Controls.Add(Type:=msoControlButton, ID:=2950)
Set ctButton4 = .Controls.Add(Type:=msoControlButton, ID:=2950)
.Visible = True
.Width = 60
End With
With ctButton1
.Style = msoButtonIconAndCaption
.Caption = "Random Colors"
.FaceId = 1763
.OnAction = "SetPicklist"
End With
With ctButton2
.Style = msoButtonIconAndCaption
.Caption = "&UnHide Sheet Tabs" '& vbCr & "This will UnHide the Sheet Tabs, if hidden"
.FaceId = 246
.OnAction = "SetDefaults"
End With
With ctButton3
.Style = msoButtonIconAndCaption
.Caption = "&Hide Sheet Tabs"
.FaceId = 244
.OnAction = "SetDefaults1"
End With
With ctButton4
.Style = msoButtonIconAndCaption
.Caption = "&Sheet Visibility"
.FaceId = 2174
.OnAction = "VisibilitySettings"
End With
End Sub
Bookmarks