Dynamically disable custom (VBA) Excel context menu buttons?
Posted
by
Lopsided
on Stack Overflow
See other posts from Stack Overflow
or by Lopsided
Published on 2014-08-19T16:17:24Z
Indexed on
2014/08/19
16:19 UTC
Read the original article
Hit count: 209
The Scenario
Hi guys, I am about to add a few custom controls to the cell context menu in my Excel workbook using the instructions found on this MSDN page. The only problem I am having is that I need the items to only be enabled for a specific column/range of cells.
I've looked around, and I've been unable to find any steps for this--there are some for VSTO development (written in C#), but that is not what I need. I plan to write this using the VBA IDE built into Office, and perhaps a bit of XML using the Custom UI Editor.
The Question
So basically, I'm looking for a way to run a function at the time the context menu is called (i.e., upon right-click) that validates the selection to make sure it is in the appropriate column. If it isn't, I would like my custom buttons to be greyed out.
P.S.
Please don't think I am asking you to write my code. Creating these buttons should be very simple, as I have created many before (albeit they were all Ribbon items), and I hope it is okay to ask for some quick assistance on this very specific issue.
Thank you in advance!
© Stack Overflow or respective owner