Excel - Edit Mode

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

Excel - Edit Mode
How to identify Excel Edit Mode to disable/enable Controls 
Ralf Garbe




Posts: 20
Joined: 2014-11-22
Hello,
Is there a way to enable and disable AddIn Controls when a user is entering in the Edit Mode, means while a cell is edited.
I would like to enable and disable the AddIn Controls at the same time as Excel is doing it for the standard controls.

Thanks,
Ralf
Posted 12 Sep, 2017 15:11:07 Top
Andrei Smolin


Add-in Express team


Posts: 18825
Joined: 2006-05-11
Hello Ralf,

You can intercept the ADXExcelAppEvents.CommandBarsUpdate event, and use the CommandBars.GetEnabledMso() method to find when Excel changes the enabled state of its built-in control. When the state changes, you change the enabled state of your controls.


Andrei Smolin
Add-in Express Team Leader
Posted 13 Sep, 2017 05:13:44 Top
Ralf Garbe




Posts: 20
Joined: 2014-11-22
Hello Andrei,
thanks for the solution. Do you have a short example since the ADXExcelAppEvents.CommandBarsUpdate event is not part of the standard event handlers of the TADXExcelAppEvents component.

Thanks and Regards,
Ralf
Posted 13 Sep, 2017 14:44:16 Top
Andrei Smolin


Add-in Express team


Posts: 18825
Joined: 2006-05-11
Hello Ralf,

My bad. I've missed the fact that you write in Delphi. Sorry for this.

You need to get the CommandBars collection object using ExcelApp.CommandBars. Then you need to connect to the CommandBars.OnUpdate event. You can find a description of this event at https://msdn.microsoft.com/en-us/vba/office-shared-vba/articles/commandbars-onupdate-event-office. On that page, the short description of the event is somewhat incorrect: in an old document they described this event as follows:

The CommandBars collection supports the OnUpdate event, which is triggered in response to changes made to a Microsoft??? Office document that might affect the state of any visible command bar or command bar control. For example, the OnUpdate event occurs when a user changes the selection in an Office document.


That is, this event is raised often and your code in the event handler must be effective to prevent degradation of the user experience.

You can find a .NET-based example using this event at https://www.add-in-express.com/creating-addins-blog/2012/02/21/excel-shapes-events/. In that add-in, I use this event to analyze the selection and create events missing in the Excel object model. There's no Delphi version of that example.


Andrei Smolin
Add-in Express Team Leader
Posted 14 Sep, 2017 02:30:32 Top