sigrist
Programmer
- Apr 24, 2011
- 2
The code creates a menu in the commandbar, where all of the buttons reach too far, however I am not able to resize it via the .Width command.
I have tried in Word 2007 and 2010.
Can you help me?
Thanks
Daniel
Sub Menu()
Dim cbrWiz As CommandBar
Dim ctlInsert As CommandBarButton
On Error Resume Next
Set cbrWiz = CommandBars("Menu")
If cbrWiz Is Nothing Then
Err.Clear
Set cbrWiz = CommandBars.Add("Menu")
' Add button control.
For x = 1 To 20 Step 1
Set ctlInsert = cbrWiz.Controls.Add
With ctlInsert
.Caption = "The text in this field is very long................" & x
.Style = msoButtonCaption
.TooltipText = "Macro" & x
.Tag = "NewMacros" & x
.OnAction = "Button" & x
End With
Next x
cbrWiz.Visible = True
cbrWiz.Width = 60
Else
cbrWiz.Visible = True
End If
I have tried in Word 2007 and 2010.
Can you help me?
Thanks
Daniel
Sub Menu()
Dim cbrWiz As CommandBar
Dim ctlInsert As CommandBarButton
On Error Resume Next
Set cbrWiz = CommandBars("Menu")
If cbrWiz Is Nothing Then
Err.Clear
Set cbrWiz = CommandBars.Add("Menu")
' Add button control.
For x = 1 To 20 Step 1
Set ctlInsert = cbrWiz.Controls.Add
With ctlInsert
.Caption = "The text in this field is very long................" & x
.Style = msoButtonCaption
.TooltipText = "Macro" & x
.Tag = "NewMacros" & x
.OnAction = "Button" & x
End With
Next x
cbrWiz.Visible = True
cbrWiz.Width = 60
Else
cbrWiz.Visible = True
End If