Hello:
Each time I run ExcelAsyncUtil.QueueAsMacro, the entire Excel’s Undo history is deleted.
See the solution at https://www.dropbox.com/s/8wcxg01sz8stpkc/UndoTester.zip and in Excel, run the method =TestAsyncArrayAutoResize("HI").
Is there a way to preserve the Excel’s UNDO history when running ExcelAsyncUtil.QueueAsMacro???
Govert:
thanks for this. I believe there is a way to capture the contents of the Undo stack before you call the QueueAsMacro and then to recover it.
I am on this and will advise if I get anywhere.
All my best.
--
You received this message because you are subscribed to the Google Groups "Excel-DNA" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
exceldna+u...@googlegroups.com.
To post to this group, send email to exce...@googlegroups.com.
Visit this group at http://groups.google.com/group/exceldna.
For more options, visit https://groups.google.com/groups/opt_out.
Hi:
I will summarize all the research findings in a blog article once I finish.
Key insights:
1. The Undo stack is available at
dynamic xlApp = ExcelDnaUtil.Application;
var undoControl = xlApp.CommandBars("Standard").Controls("&Undo").Control;
var list = new List<string>();
for (var i = 1; i <= undoControl.ListCount; ++i)
{
list.Add(undoControl.List[i]);
}
However, this is only read-only and I cannot write there anything back. I have been unable to find any web page where this has been
done.
Does anybody know how to write to that Undo Control???? There are some articles claiming that it’s not possible by design, but I guess there must be a C++ way. Anybody knows how?
2.
The Default ApplicationOnUndo are only 1-step back undo support and it entirely wipes the default undo stack.
3. Having said that, there is nothing which stops me from implementing my own undo using the code below where I would keep a stack of all changes and somehow trimming the stack when the sheet gets closed etc etc etc
dynamic xlApp = ExcelDnaUtil.Application;
((AppEvents_Event)xlApp).SheetChange += (sh, target) =>
{
try
{
ExcelAsyncUtil.QueueAsMacro(() =>
{
var formula = target.Formula;
});
}
catch
{
}
};
And then assigning the undo to my own shortcut key, say CTRL+SHIFT+Z.
There are some exceptional cases to be considered, but it’s easily doable.
What are your thoughts on this? I can prepare a simple library for this & share it for a feedback.
Hi Everyone:
I got a working Undo solution whose architecture works with macros, Excel-DNA functions etc.
Check out the article http://jiripik.me/2014/01/27/how-to-support-excel-undo-and-redo-with-excel-dna/
Any feedback is much appreciated.
Yes, I have just tried it and it works well.
BUT there are some extreme cases which still needs to be taken care of. Left as an exercise …. hehehehe
From: exce...@googlegroups.com [mailto:exce...@googlegroups.com]
On Behalf Of Naju Mancheril
Sent: Monday, January 27, 2014 5:28 PM
To: exce...@googlegroups.com
Subject: Re: [ExcelDna] Re: ExcelAsyncUtil.QueueAsMacro is breaking the UNDO history
Are you storing other actions in your stack besides cell value changes? For example, if I delete a column, can I undo that as well with Ctrl+Shift+Z?
--
Govert:
Thanks for the feedback! Yes, it’s just a proof of concept which seems to work and now it’s time to get into the details. hehehe
Re: Listeners I am having funny problems with crashing Excel which can be only solved with the attribute [HandleProcessCorruptedStateExceptions]
Ø When I tried it, entering a few different cells on a sheet, I could only Undo a single action with Ctrl+Z.
You should try CTRL+SHIFT+Z. That’s what I am listening to, but yes, I will overwrite the default keyboard shortcut later.
I will be working on the improvements as time allows (very little for this), if anybody wants to help out, it would be much appreciated – the project is public source on github.
All my best.
Gareth:
I do know how to make it more robust by intercepting the Commands structure of Excel but have no time for this now, unfortunately.
The code has been removed since I am redesigning the entire website and since the code needs some changes.
For more options, visit https://groups.google.com/d/optout.