Driving me crazy....
This works on other pc's but not on mine anymore.
When I open the workbook this used to work flawlessly: a floating toolbar with macros assigned...
Sub Auto_Open()
Dim cbr As CommandBar, ctl As CommandBarControl
' create a new commandbar called 'tester'
Set cbr = CommandBars.Add("MACROS", , , True)
' add a control to it
Set ctl = cbr.Controls.Add(msoControlButton, , , , True)
With ctl
.Caption = "Import TransposedJobStream.xls"
' assign the macro
.OnAction = "ONE"
' set the button to display text
.Style = msoButtonCaption
End With
' repeat steps for other controls
Set ctl = cbr.Controls.Add(msoControlButton, , , , True)
With ctl
.Caption = "Import exported JSC 'All Calendars' view"
.OnAction = "TWO"
.Style = msoButtonCaption
End With
Set ctl = cbr.Controls.Add(msoControlButton, , , , True)
With ctl
.Caption = "XREF"
.OnAction = "THREE"
.Style = msoButtonCaption
End With
With cbr
' create a floating toolbar
.Position = msoBarFloating
.Height = 100
.Width = 50
' show the toolbar
.Visible = True
End With
End Sub
Since yesterday I get "Runtime error '5' Invalid procedure call or argument".
The error points to: Set cbr = CommandBars.Add("MACROS", , , True) on line 4.
What could suddenly be causing this. Fact is that I have been tinkering on macros for a while but how that could make this stop working is a mystery to me.
I use the same code on other .xlt files but they end similarly in error (whereas before it worked fine).
What can possibly be the cause of this. I've tried closing personal.xls or any other file holding code, rebooted the pc, .... As said, on other pc this does still work.
Your help will be greatly appreciated.
Thanks.