Hello, all.
A question for the gurus. I have been using the now classic VBA Undo Group tricks on most of my Macros with excellent results. Like this:
Sub boostStart(Optional unDo$) On Error Resume Next 'Thanks for the cursor, Shelby! CorelScriptTools.BeginWaitCursor If Len(unDo) Then ActiveDocument.BeginCommandGroup unDo Optimization = True EventsEnabled = False ActiveDocument.SaveSettings End Sub Sub boostFinish(Optional ByVal endUndoGroup As Boolean = False) On Error Resume Next ActiveDocument.RestoreSettings Optimization = False EventsEnabled = True If endUndoGroup Then ActiveDocument.EndCommandGroup ActiveWindow.Refresh End Sub
And it works great. But I have run into a bit of trouble if another macro also uses it. For example, a commercial one that is locked up, but allows for calling its functions.
So if I have my own macro that does something to the document, then calls the outside macro that seemingly also calls "Optimization" and or "ActiveDocument.EndCommandGroup" the Undo becomes a mess with some parts being nicely grouped, but others not. Is there some other way to create an undo that works like a straight up copy of the document before an action and then returning to that point of necessary? Sure, saving works, but the risk of forgetting that (user error) is always a concern.
Thank you in advance.
So, do not use this way (involving two subs), anymore.
Start the Sub with `ActiveDocument.BeginCommandGroup "DoingSomething"` and end it with `ActiveDocument.EndCommandGroup`
You can use them only for optimization, if you want proceeding in this way.
Thanks for the turbo reply.
I get that, but a function (that cannot be edited, because it is third party and locked) that is called between these two has its own "EndCommandGroup" and "Optimization = False" inside. So what I need is somehow grouping all those commands (several BeginCommandGroup and EndCommandGroup together).
Actually, to be more precise, a couple of Undos would not hurt too much, as long as each function has one parent step and not each step inside a function after another calls the EndCommandGroup and disables optimization.