Is there a way to create an event so that a certain .xlam of mine gets control whenever the user right-clicks ? In this case the user may have several .xlsx (non-macro) workbooks open which must remain free of any macro code. If the user right-clicks while one of these macro-free worksheets is open, I’d like the .xlam to gain control and possibly do something.
Use a with events variable in a class such as
Private WithEvents mxlApp As Excel.Application
Then use the event SheetBeforeRightClick.
Private Sub mxlApp_SheetBeforeRightClick(ByVal Sh As Object, ByVal Target As Range, Cancel As Boolean) End Sub
The xlsx files should have the .xlam file installed in order for it to work. Hope this helps.