I am considering implementing an Excel add-in using COM (not VBA) that will manipulate data in the worksheet.
I am going to need this add-in to seamlessly integrate with the Undo stack.
More specifically:
- Any changes this add-in makes to the data need to be undoable by the user (through the standard Undo action)
- The items on the Undo stack before the add-in action takes place need to be preserved
In my (albeit perfunctory) research so far, it is unclear whether or not Excel can allow for this. If it does not, this is a showstopper, and the add-in will have no value.
My question: is it possible? This is more of a “yes or no” question than a “how” question, as I need to know if I am embarking on a wild goose chase or not. However, any pointers on how it can be done would be a bonus.
Seems like it is not possible after all.
The
Application.OnUndomethod clears the current undo stack and places itself on top.There doesn’t seem to be anything else related to customizing undo.
It is possible.Application.OnUndoregisters an undo sub for the currently executing sub:Obviously, saving a previous state in the wild is generally a nightmare. But here you go.
Also, your undo sub will need to be visible to the general public so that Excel can find and call it.