Custom Toolbar
I've been reading about adding custom commands/buttons/macros to a toolbar
and need some help. I would like to be able to have a macro check for a certain button on the "Standard" tool bar, and if it's not present, then add the button, and assign a macro. Your help would be greatly appreciated. I have tried it using the techniques I have seen, but obviously I am missing something. |
Custom Toolbar
Hi Josh
Delete the button first in the code before you add it with code. Something like this Sub MenuBar_Item() Call MenuBar_Item_Delete With Application.CommandBars("Standard") With .Controls.Add(Type:=msoControlButton, temporary:=True, befo=1) .Style = msoButtonCaption .Caption = "&Hi" .TooltipText = "Hi again" .OnAction = ThisWorkbook.Name & "!TestMacro1" .Tag = "MyTag1" End With End With End Sub Sub MenuBar_Item_Delete() On Error Resume Next Application.CommandBars.FindControl(Tag:="MyTag1") .Delete On Error GoTo 0 End Sub -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "Josh O." wrote in message ... I've been reading about adding custom commands/buttons/macros to a toolbar and need some help. I would like to be able to have a macro check for a certain button on the "Standard" tool bar, and if it's not present, then add the button, and assign a macro. Your help would be greatly appreciated. I have tried it using the techniques I have seen, but obviously I am missing something. |
All times are GMT +1. The time now is 09:28 PM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com