ecawilkinson
11-19-2019, 04:17 AM
Hi,
I have manged to create a custom toolbar in the VB IDE (VBA Editor), with 2 buttons that are visible and enabled. I have an addin named "ChrisRibbon.xlam", which has code that runs when various buttons on the ribbon are pressed. I want to add a procedure (a sub) into that workbook and have it called when I press one of the buttons of the toolbar in the VBA editor (toolbar called ChrisExtras). I tried to do this by the following code:
dim btn as CommandBarButton
Set btn = Application.VBE.CommandBars("ChrisExtras").Controls(1)
btn.OnAction = "ChrisRibbon.xlam!AddSub" ' the code should add a skeleton sub to the active codepane
I have tried various different syntaxes for the OnAction property but nothing works. I do not even get an error message. It will not even run it if I make OnAction = "=MsgBox(""Hi World!"")". The above code does not give any error message, it just runs and finishes. If I query btn.OnAction, it shows exactly what I entered, so I have no idea what is going on. Any help would be much appreciated.
thanks,
Chris
I have manged to create a custom toolbar in the VB IDE (VBA Editor), with 2 buttons that are visible and enabled. I have an addin named "ChrisRibbon.xlam", which has code that runs when various buttons on the ribbon are pressed. I want to add a procedure (a sub) into that workbook and have it called when I press one of the buttons of the toolbar in the VBA editor (toolbar called ChrisExtras). I tried to do this by the following code:
dim btn as CommandBarButton
Set btn = Application.VBE.CommandBars("ChrisExtras").Controls(1)
btn.OnAction = "ChrisRibbon.xlam!AddSub" ' the code should add a skeleton sub to the active codepane
I have tried various different syntaxes for the OnAction property but nothing works. I do not even get an error message. It will not even run it if I make OnAction = "=MsgBox(""Hi World!"")". The above code does not give any error message, it just runs and finishes. If I query btn.OnAction, it shows exactly what I entered, so I have no idea what is going on. Any help would be much appreciated.
thanks,
Chris