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.
Joe,
I have run into this also. I normally have chosen not to do the undo since I have no control over the other code. I just do not want them conflicting.
I wish I have found a more graceful way to handle it.
-Shelby
Well, if Shelby does not have a solution then there probably isn't one. I'm just going to bombard all the other functions into CommandGroups and have to live with 3-4 extra undo steps for each branch of the function.