How To Add Label And Text On Button In Custom Toolbar Of Excel 2000?
I have to add a custom toolbar that should contain label and button in Excel 2000. I am not able to use msoControlLable and msoControlButton properly. If i m using msoControlButton then caption (text) does not display on runtime. Can somebody help me?
Dim cbBar As CommandBar, cbCtrl1 As CommandBarControl, cbCtrl2 As CommandBarControl
Call DeleteTMCToolbar
Set cbBar = CommandBars.Add(Name:=cCommandBarID, Position:=msoBarTop)
Set cbCtrl1 = cbBar.Controls.Add(Type:=msoControlButton)
With cbCtrl1 '
.BeginGroup = False
.DescriptionText = "Gen"
.DescriptionText = 0
.FaceId = 0
.Caption = "DFA555SDA"
.TooltipText = "General"
'.Name = "Padam"
' .Caption = "TMC"
' .DescriptionText = "Dfasdfas"'
End With
Set cbCtrl2 = cbBar.Controls.Add(Type:=msoControlEdit)
With cbCtrl2
.Caption = "TMC1"
.DescriptionText = "Dfasdfas" '
End With
First of all thanks for your great help. It is working fine.
Now i want to have only Text in custom toolbar. How can i achieve it?
If i am using msoCustomButton with caption only then click event is enable. I do not want that click event.
My requirement is simple text like 'Get Company Report' and it should not be clickable. Can you help me.
Dim cbBar As CommandBar, cbCtrl1 As CommandBarControl, cbCtrl2 As CommandBarControl
Call DeleteTMCToolbar
Set cbBar = CommandBars.Add(Name:=cCommandBarID, Position:=msoBarTop)
Set cbCtrl1 = cbBar.Controls.Add(Type:=msoControlButton)
With cbCtrl1 '
.BeginGroup = False
.DescriptionText = "Gen"
.DescriptionText = 0
.FaceId = 0
.Caption = "DFA555SDA"
.TooltipText = "General"
'.Name = "Padam"
' .Caption = "TMC"
' .DescriptionText = "Dfasdfas"'
End With
Set cbCtrl2 = cbBar.Controls.Add(Type:=msoControlEdit)
With cbCtrl2
.Caption = "TMC1"
.DescriptionText = "Dfasdfas" '
End With
First of all thanks for your great help. It is working fine.
Now i want to have only Text in custom toolbar. How can i achieve it?
If i am using msoCustomButton with caption only then click event is enable. I do not want that click event.
My requirement is simple text like 'Get Company Report' and it should not be clickable. Can you help me.
' -------------------------------------
Dim cbBar As CommandBar
Set cbBar = CommandBars("Test")
Dim cbBtnNew As CommandBarButton
Set cbBtnNew = cbBar.Controls.Add(msoControlButton)
With cbBtnNew
.FaceId = 5
.Caption = "Test Button"
.Style = msoButtonIconAndCaption
End With
' -------------------------------------
Besides the Style property, your problem may have been that you didn't choose a valid FaceId. See the link below for a tool to enumerate them for you.
Hope that helps.
Dim cbBar As CommandBar
Set cbBar = CommandBars("Test")
Dim cbBtnNew As CommandBarButton
Set cbBtnNew = cbBar.Controls.Add(msoControlButton)
With cbBtnNew
.FaceId = 5
.Caption = "Test Button"
.Style = msoButtonIconAndCaption
End With
' -------------------------------------
Besides the Style property, your problem may have been that you didn't choose a valid FaceId. See the link below for a tool to enumerate them for you.
Hope that helps.
' -------------------------------------
Dim cbBar As CommandBar
Set cbBar = CommandBars("Test")
Dim cbBtnNew As CommandBarButton
Set cbBtnNew = cbBar.Controls.Add(msoControlButton)
With cbBtnNew
.FaceId = 5
.Caption = "Test Button"
.Style = msoButtonIconAndCaption
End With
' -------------------------------------
Besides the Style property, your problem may have been that you didn't choose a valid FaceId. See the link below for a tool to enumerate them for you.
Hope that helps.
Dim cbBar As CommandBar
Set cbBar = CommandBars("Test")
Dim cbBtnNew As CommandBarButton
Set cbBtnNew = cbBar.Controls.Add(msoControlButton)
With cbBtnNew
.FaceId = 5
.Caption = "Test Button"
.Style = msoButtonIconAndCaption
End With
' -------------------------------------
Besides the Style property, your problem may have been that you didn't choose a valid FaceId. See the link below for a tool to enumerate them for you.
Hope that helps.