ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   msoControlButtonDropDown (https://www.excelbanter.com/excel-programming/296837-msocontrolbuttondropdown.html)

Zic

msoControlButtonDropDown
 
Hi all
Could somebody explain why with this code below i keep getting a #5 error
message?
Sub Affiche_Barre()
Dim Barre As CommandBar, boutDrpDwn As CommandBarControl, bout1 As
CommandBarButton, bout2 As CommandBarButton
Set Barre = Application.CommandBars.Add(MaCommandeBar, msoBarTop, ,
True)
Set boutDrpDwn = Barre.Controls.Add(msoControlButtonDropdown)
With boutDrpDwn
.FaceId = 135
End With
Set bout1 = boutDrpDwn.Controls.Add(msoControlButton)
With bout1
.FaceId = 71
.Style = msoButtonIcon
.OnAction = "MacroBout1"
End With
Set bout2 = boutDrpDwn.Controls.Add(msoControlButton)
With bout2
.FaceId = 72
.Style = msoButtonIcon
.OnAction = "MacroBout2"
End With
End Sub

TIA
Zic



Bob Phillips[_6_]

msoControlButtonDropDown
 
Zic,

Try this

Dim Barre As CommandBar, boutDrpDwn As CommandBarControl, bout1 As
CommandBarButton, bout2 As CommandBarButton
Set Barre = Application.CommandBars.Add("Bob", msoBarTop, , True)
Barre.Visible = True
Set boutDrpDwn = Barre.Controls.Add(Type:=msoControlDropdown)
With boutDrpDwn
'.FaceId = 135
End With
With Barre
Set bout1 = .Controls.Add(msoControlButton)
With bout1
.FaceId = 71
.Style = msoButtonIcon
.OnAction = "MacroBout1"
End With
Set bout2 = .Controls.Add(msoControlButton)
With bout2
.FaceId = 72
.Style = msoButtonIcon
.OnAction = "MacroBout2"
End With
End With


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Zic" <nospam@thanks wrote in message
...
Hi all
Could somebody explain why with this code below i keep getting a #5 error
message?
Sub Affiche_Barre()
Dim Barre As CommandBar, boutDrpDwn As CommandBarControl, bout1 As
CommandBarButton, bout2 As CommandBarButton
Set Barre = Application.CommandBars.Add(MaCommandeBar, msoBarTop, ,
True)
Set boutDrpDwn = Barre.Controls.Add(msoControlButtonDropdown)
With boutDrpDwn
.FaceId = 135
End With
Set bout1 = boutDrpDwn.Controls.Add(msoControlButton)
With bout1
.FaceId = 71
.Style = msoButtonIcon
.OnAction = "MacroBout1"
End With
Set bout2 = boutDrpDwn.Controls.Add(msoControlButton)
With bout2
.FaceId = 72
.Style = msoButtonIcon
.OnAction = "MacroBout2"
End With
End Sub

TIA
Zic





Zic

msoControlButtonDropDown
 
Hi Bob
Thank you for your answer and suggestion
Unfortunately this is not working for me (My commandbar - MaCommandeBar -
has its name placed as Const on top of my module)
and besides the amendments you made particularly to
Type:=msoControlDropdown
do not suit me since i would like a "real" msoControlButtonDropdown ie like
the one in the borders button from the Formatting tool bar
I still cannot figure why this is not working for me?
Any more ideas?
TIA
Rgrds

"Bob Phillips" a écrit dans le message
de news: ...
Zic,

Try this

Dim Barre As CommandBar, boutDrpDwn As CommandBarControl, bout1 As
CommandBarButton, bout2 As CommandBarButton
Set Barre = Application.CommandBars.Add("Bob", msoBarTop, , True)
Barre.Visible = True
Set boutDrpDwn = Barre.Controls.Add(Type:=msoControlDropdown)
With boutDrpDwn
'.FaceId = 135
End With
With Barre
Set bout1 = .Controls.Add(msoControlButton)
With bout1
.FaceId = 71
.Style = msoButtonIcon
.OnAction = "MacroBout1"
End With
Set bout2 = .Controls.Add(msoControlButton)
With bout2
.FaceId = 72
.Style = msoButtonIcon
.OnAction = "MacroBout2"
End With
End With


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Zic" <nospam@thanks wrote in message
...
Hi all
Could somebody explain why with this code below i keep getting a #5

error
message?
Sub Affiche_Barre()
Dim Barre As CommandBar, boutDrpDwn As CommandBarControl, bout1 As
CommandBarButton, bout2 As CommandBarButton
Set Barre = Application.CommandBars.Add(MaCommandeBar, msoBarTop, ,
True)
Set boutDrpDwn = Barre.Controls.Add(msoControlButtonDropdown)
With boutDrpDwn
.FaceId = 135
End With
Set bout1 = boutDrpDwn.Controls.Add(msoControlButton)
With bout1
.FaceId = 71
.Style = msoButtonIcon
.OnAction = "MacroBout1"
End With
Set bout2 = boutDrpDwn.Controls.Add(msoControlButton)
With bout2
.FaceId = 72
.Style = msoButtonIcon
.OnAction = "MacroBout2"
End With
End Sub

TIA
Zic








All times are GMT +1. The time now is 05:31 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com