S
Simon
I have a handful of macros that I distribute to my coleagues as an addin...
As the number of Macros has grown, I'm trying to use a toolbar to access the
macro's, however I'm getting the above runtime error when I try and generate
the bar dynamically.
code looks like this (mind the wrap)-
*****************************************************************************
Set CBSBar = CommandBars.Add(Name:="CBSBar", Position:=msoBarLeft,
temporary:=True)
With CBSBar
.Visible = True
End With
For i = 1 To 6
Select Case i
Case 1
CBSBar.Controls.Add(Type:=msoControlButton, ID:=i).Caption =
"caption 1"
With CBSBar.Controls(i)
.Style = msoButtonIcon
.FaceId = 2147
.OnAction = "xxx"
.TooltipText = "Blah blah blah"
End With
Case 2
CBSBar.Controls.Add(Type:=msoControlButton, ID:=i).Caption =
"Caption 2"
With CBSBar.Controls(i)
.Style = msoButtonIcon
.OnAction = "xxx"
.FaceId = 2150
.TooltipText = "Blah Blah Blah"
End With
Case 3
CBSBar.Controls.Add(Type:=msoControlButton, ID:=i).Caption = "caption
3"
With CBSBar.Controls(i)
.Style = msoButtonIcon
.OnAction = "xxx"
.FaceId = 2149
.TooltipText = "blah blah blah"
End With
Case 4
CBSBar.Controls.Add(Type:=msoControlButton, ID:=i).Caption = "caption
4"
With CBSBar.Controls(i)
.FaceId = 233
.Style = msoButtonIcon
.OnAction = "xxx"
.TooltipText = "blah blah blah"
.BeginGroup = True
End With
Case 5
CBSBar.Controls.Add(Type:=msoControlButton, ID:=i).Caption = "caption
5"
With CBSBar.Controls(i)
.Style = msoButtonIcon
.FaceId = 659
.OnAction = "xxx"
.TooltipText = "blah blah blah"
End With
Case 6
CBSBar.Controls.Add(Type:=msoControlButton, ID:=i).Caption =
"caption 6"
With CBSBar.Controls(i)
.Style = msoButtonIcon
.FaceId = 684
.OnAction = "xxx"
.TooltipText = "blah blah blah"
End With
end select
*****************************************************************************
code works fine (ie it adds a new toolbar, and starts to populate it with
buttons) until the 5th increment where it generates a runtime error.
I note from the MS site that this is an acknowledged 'bug', but I can't make
sense of their 'fix' in this context (ie the nominated example uses shortcut
menu's and I can't work out how that translates to a toolbar). Google
returns thousands of hits on this error however they mainly appear to be in
relation to access/sql or ASP errors (no help whatsoever...)
Any/all assistance gratefully received
TIA
S
As the number of Macros has grown, I'm trying to use a toolbar to access the
macro's, however I'm getting the above runtime error when I try and generate
the bar dynamically.
code looks like this (mind the wrap)-
*****************************************************************************
Set CBSBar = CommandBars.Add(Name:="CBSBar", Position:=msoBarLeft,
temporary:=True)
With CBSBar
.Visible = True
End With
For i = 1 To 6
Select Case i
Case 1
CBSBar.Controls.Add(Type:=msoControlButton, ID:=i).Caption =
"caption 1"
With CBSBar.Controls(i)
.Style = msoButtonIcon
.FaceId = 2147
.OnAction = "xxx"
.TooltipText = "Blah blah blah"
End With
Case 2
CBSBar.Controls.Add(Type:=msoControlButton, ID:=i).Caption =
"Caption 2"
With CBSBar.Controls(i)
.Style = msoButtonIcon
.OnAction = "xxx"
.FaceId = 2150
.TooltipText = "Blah Blah Blah"
End With
Case 3
CBSBar.Controls.Add(Type:=msoControlButton, ID:=i).Caption = "caption
3"
With CBSBar.Controls(i)
.Style = msoButtonIcon
.OnAction = "xxx"
.FaceId = 2149
.TooltipText = "blah blah blah"
End With
Case 4
CBSBar.Controls.Add(Type:=msoControlButton, ID:=i).Caption = "caption
4"
With CBSBar.Controls(i)
.FaceId = 233
.Style = msoButtonIcon
.OnAction = "xxx"
.TooltipText = "blah blah blah"
.BeginGroup = True
End With
Case 5
CBSBar.Controls.Add(Type:=msoControlButton, ID:=i).Caption = "caption
5"
With CBSBar.Controls(i)
.Style = msoButtonIcon
.FaceId = 659
.OnAction = "xxx"
.TooltipText = "blah blah blah"
End With
Case 6
CBSBar.Controls.Add(Type:=msoControlButton, ID:=i).Caption =
"caption 6"
With CBSBar.Controls(i)
.Style = msoButtonIcon
.FaceId = 684
.OnAction = "xxx"
.TooltipText = "blah blah blah"
End With
end select
*****************************************************************************
code works fine (ie it adds a new toolbar, and starts to populate it with
buttons) until the 5th increment where it generates a runtime error.
I note from the MS site that this is an acknowledged 'bug', but I can't make
sense of their 'fix' in this context (ie the nominated example uses shortcut
menu's and I can't work out how that translates to a toolbar). Google
returns thousands of hits on this error however they mainly appear to be in
relation to access/sql or ASP errors (no help whatsoever...)
Any/all assistance gratefully received
TIA
S