Closed rwemay closed 1 year ago
Are you experiencing this reliably or sporadically? I can't seem to reproduce myself.
Found the issue: When we do things that modify the workbook, like selecting an item from globalsearch or the ribbon UI, we have to do so by queuing the change as a macro. According to the following answer on stack overflow:
there is not way to stop a worksheet-changing macro from clearing the undo stack.
https://stackoverflow.com/questions/7798575/undo-history-button-clear-after-run-macro-excel
As far as I have been able to tell you have to have this work run from a macro context because it is making changes to the sheet but I will check this to be certain. If that is the case we'll probably need to create our own Undo stack and override that of excel itself, no doubt this will be fraught with complexity to make it behave exactly as excel does normally.
After looking into this, I confirm this is related to calling QueueAsMacro
. Some of those calls can be removed but it seems difficult to find a way around using macros. The undo stack is cleared when
This problem is not due to Excel DNA and is part of Excel: when a macro is ran, the undo stack is cleared since macros can make large scale changes to multiple spreadsheets so an undo there would be a bit complicated (well, still possible but it looks like Microsoft didn't want to bother).
I don't want to have our own undo stack as it would potentially affect the normal usage of Excel (and would also be quite painful to make sure we cover everything). So I can only think of two possibilities:
Since it looks like solving this is going to require a decent amount of investigation and time, I will put this on hold for this quarter unless I run out of things to do.
I had a final look at this today.
xlexcel.CommandBars["Standard"].Controls["&Undo"]
but this is obviously a read-only so no very useful.I am marking this issue as parked as I don't see a solution to this. Hopefully we will not have too many of those type of issues but I created a wiki page to document them properly.
Closing as parked for a few years
Description:
Undo doesn't work for some functions, for example add/remove columns/rows in a spreadsheet.
How to replicate:
Try to add/remove columns/rows in a spreadsheet with BHoM forumulae in and see if the undo function works.
Expected behaviour:
Test file(s):