You may use:
You may call this code from Workbook_Open event of your add-in.![]()
Sub addButton() Dim cbr As CommandBar Dim ctl As CommandBarControl Set cbr = Application.CommandBars("Cell") Set ctl = cbr.Controls.Add(msoControlButton, , , , True) With ctl .Caption = "Execute macro" .OnAction = "'" & ThisWorkbook.Name & "'!Macro_name" .Style = msoButtonCaption End With End Sub
Bookmarks