felipegualberto's avatar
felipegualberto
Copper Contributor
Feb 09, 2025
Status:
New

Extend OfficeExtension.EventHandlerResult API

Notice: this would benefit all Apps for Office Addins that expose events with OfficeExtension.EventHandlerResult<>.

Currently, when adding an event handler to Excel.Table.onSelectionChanged, the returned OfficeExtension.EventHandlerResult object is only valid within the current JavaScript session. If the session is lost (e.g., due to add-in reload, debugging, or errors), there is no way to retrieve and remove previously attached event handlers.

This leads to "zombie" event handlers accumulating in an Excel session, particularly during development. While removeAll() is an option, it indiscriminately removes all handlers, including those registered by other add-ins, which is not ideal.

  • There is no way to enumerate existing event handlers attached to an event.
  • There is no way to retrieve a reference to a previously attached handler after the session is lost.
  • There is no unique ID assigned to handlers that would allow selective removal.

I propose adding an API to manage event handlers more effectively, such as:

  • Retrieve a list of active handlers for a given event (getHandlers() method).
  • Assign unique, retrievable IDs to event handlers, allowing for selective removal (removeById(id)).
No CommentsBe the first to comment