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.
alternatively, before calling another macro, you could make a copy of your shapes and move it on a separate layer. Didn't like the result after outside macro - copied it back
Well, that sounds like an option for simpler shapes and documents. But if it's a multipage (20+)/multilayer(3+) document (which is the case most of the time) where objects get moved around between pages that becomes way too complex.
Sounds like I may have to look into some temp file saving before running the macro to avoid user errors.