I have an Excel Add-In that I have created ( .xlam file ) I am trying to have this add-in create buttons on the right click menu so that I can quickly run a macro based on the selected cell. I added code to ThisWorkbook, and it works in the xlsm file. (I copied the code from HERE.) I SaveAs to an xlam, load the add-in, and I get nothing on the context menu. I have a feeling these subs do not load through the add-in. However, I can get code in Workbook_Open to function. Can someone point me in the right direction?
Private Sub Workbook_Deactivate()
On Error Resume Next
With Application
.CommandBars("Cell").Controls("Open Drawing").Delete
End With
On Error GoTo 0
End Sub
Private Sub Workbook_SheetBeforeRightClick(ByVal Sh As Object, ByVal Target As Range, Cancel As Boolean)
Dim cmdBtn As CommandBarButton
On Error Resume Next
With Application
.CommandBars("Cell").Controls("Open Drawing").Delete
Set cmdBtn = .CommandBars("Cell").Controls.Add(Temporary:=True)
End With
With cmdBtn
.Caption = "Open Drawing"
.Style = msoButtonCaption
.OnAction = "Open_Drawing_Main"
End With
On Error GoTo 0
End Sub