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:
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.OnUndo
method 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.OnUndo
registers an undo sub for the currently executing sub:
sub ImMakingChanges()
cells(1,1).interior.color = vbyellow
application.onundo "Undo the stupid color", "RemoveMyStupidChanges"
end sub
sub RemoveMyStupidChanges()
cells(1,1).interior.colorindex = xlnone
end 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.
Apparently, this is not possible and there are no plans to support it even in Office 2013, as per the response by an MSFT employee on this thread.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With