S
sydney
Hello
I am using Microsoft Office XP Developer to develop a vba com add-in for
word xp.
Using wizards I have got as far as making my toolbar work (woohoo).
My toolbar will contain atleast ten buttons and I need to know if I am doing
this the long way.
Below is the code to set the toolbar and add two buttons, do I need to dim
every commandbarbutton I need to create or is there a shorter way?
Thanks a bunch.
' Specify the command bar
Dim cbcmybar As Office.CommandBar
Dim btnMyButton As Office.CommandBarButton ' first button
Dim btnPrecTbar As Office.CommandBarButton 'second button. check if need
to cont. this pattern for every button.
Set cbcmybar = CommandBars.Add(Name:="My new toolbar")
' Specify the commandbar button
Set btnMyButton = cbcmybar.Controls.Add(Type:=msoControlButton, _
Parameter:="1")
With btnMyButton
.Style = msoButtonCaption
.BeginGroup = True
.Caption = "First butn"
.TooltipText = "this is a test"
End With
'Add another menu to the toolbar
Set btnPrecTbar = cbcmybar.Controls.Add(Type:=msoControlButton, _
Parameter:="2")
With btnPrecTbar
.Style = msoButtonCaption
.BeginGroup = True
.Caption = "second butn"
.TooltipText = "my second button"
End With
I am using Microsoft Office XP Developer to develop a vba com add-in for
word xp.
Using wizards I have got as far as making my toolbar work (woohoo).
My toolbar will contain atleast ten buttons and I need to know if I am doing
this the long way.
Below is the code to set the toolbar and add two buttons, do I need to dim
every commandbarbutton I need to create or is there a shorter way?
Thanks a bunch.
' Specify the command bar
Dim cbcmybar As Office.CommandBar
Dim btnMyButton As Office.CommandBarButton ' first button
Dim btnPrecTbar As Office.CommandBarButton 'second button. check if need
to cont. this pattern for every button.
Set cbcmybar = CommandBars.Add(Name:="My new toolbar")
' Specify the commandbar button
Set btnMyButton = cbcmybar.Controls.Add(Type:=msoControlButton, _
Parameter:="1")
With btnMyButton
.Style = msoButtonCaption
.BeginGroup = True
.Caption = "First butn"
.TooltipText = "this is a test"
End With
'Add another menu to the toolbar
Set btnPrecTbar = cbcmybar.Controls.Add(Type:=msoControlButton, _
Parameter:="2")
With btnPrecTbar
.Style = msoButtonCaption
.BeginGroup = True
.Caption = "second butn"
.TooltipText = "my second button"
End With