Disable ribbon button when Excel in edit mode

Add-in Express™ Support Service
That's what is more important than anything else

Disable ribbon button when Excel in edit mode
 
David Jones


Guest


Hi,

I am developing a COM add-in for Excel and need to disable some of my ribbon functions when the user is editing a cell (just as Excel itself does). I have read various posts here and elsewhere about the best way to determine whether Excel is in edit mode, but my problem is detecting when this occurs so that I can disable my buttons.

1) Your custom task panes have ADXBeforeCellEdit and ADXAfterCellEdit events, which would seem to be exactly what I'm looking for, but I'm not using custom task panes in my add-in. Are there equivalent events I can use in a COM add-in?

2) The other approach I tried was to use an ADXRibbonCommand to listen in to the enable event of the built-in controls, but it does not seem to be reliable. My event does fire during Excel start-up, but after that never gets called. I tried various IDMSOs that Excel disables during cell edit (for example 'IndentIncreaseExcel'), but none of them fire when a cell is edited. Should I be able to listen to these events using an ADXRibbonCommand?

I am using Excel versions 2007-2013, on various versions of windows. Behavior is always the same.

Many thanks,
David
Posted 06 Mar, 2015 05:11:08 Top
Andrei Smolin


Add-in Express team


Posts: 19172
Joined: 2006-05-11
Hello David,

David Jones writes:
I tried various IDMSOs that Excel disables during cell edit


I'd handle the CommandbarsUpdate event of the Excel Events component to check such an IDMSO using Commandbars.GetEnabledMso(); you get a CommandBars object using ExcelApp.Commandbars.

Please let me know if this works for you.


Andrei Smolin
Add-in Express Team Leader
Posted 06 Mar, 2015 07:17:44 Top
David Jones


Guest


Hi Andrei,

Your suggestion worked perfectly!

Many thanks,
David
Posted 09 Mar, 2015 09:29:02 Top
Andrei Smolin


Add-in Express team


Posts: 19172
Joined: 2006-05-11
Great!


Andrei Smolin
Add-in Express Team Leader
Posted 09 Mar, 2015 09:43:16 Top