tags:

views:

14

answers:

1

At the moment, I have code that runs in the Application's SheetBeforeRightClick event, but I've found that this code doesn't run when I press the keyboard's Context Menu key instead of using the right mouse button, which means that I get the wrong menu.

I could use the SheetSelectionChange event instead, but I'd imagine this would be quite error prone. Is there a more elegant way of doing it?

A: 

There is a BeforeContextMenu event you can use.
http://msdn.microsoft.com/en-us/library/aa193082(office.11).aspx
It should catch both the right click and the keyboard key.

ktharsis
So close! Unfortunately that's only for Web Components I think - I need it for native Excel.
Ant
Crap - good point. Does your custom menu change based on the workbook or data on the sheet itself? If it doesn't try and move it up and "high" as possible in the chain (WorkbookOpen for the app or SheetActivate for the sheet, instead of SheetSelectionChange)
ktharsis
Unfortunately on the contents of the cell :(
Ant