Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

'Group' actions in macros so they are all undone with only one 'Un

420 views
Skip to first unread message

Bourgui

unread,
Sep 8, 2008, 4:11:06 PM9/8/08
to
Hi all,

I have written macros that, among other things, set some bookmarks (working
in pairs) through a document that I use later with my tool.

The problem I have is that the actions of my macros are undone one by one,
So a user can launch the macro, then type some text or whatever else, then
decide to 'Undo' what they have just done. If they click one (or more) 'Undo'
too many, they can for example delete one of the bookmarks from pair.
Deleting a bookmark does not have a high-visual impact, so it usually goes
unnoticed until they call a macro which is supposed to use it and fails.

I give the example of a bookmark but it can be many other things, such as
hidden text insertion, font change...

Is there any way to group the actions of a macro (and all the functions it
may have called) so that they are all considered one action when it comes to
'Undo' and 'Redo'?

Powerpoint actually works the way I would like it to do in Word

Jay Freedman

unread,
Sep 8, 2008, 4:38:38 PM9/8/08
to

Yes, there is a way, but you have to set it up yourself. See
http://groups.google.com/group/microsoft.public.word.word97vba/msg/c5f120a7817f3dbb?hl=en

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.


Jonathan West

unread,
Sep 8, 2008, 4:44:38 PM9/8/08
to

"Bourgui" <Bou...@discussions.microsoft.com> wrote in message
news:6DED5F82-7382-45BE...@microsoft.com...

You have to make a custom Undo macro, and you have to start and end each
otjher macro with some defined and detectable action, such as inserting and
removing a bookmark. if you insert a bookmark at the start of the macro and
remove it at the end, then your custom macro can undo 1 action, check
whether the bookmark is present, and repeat the process until it isn't.

If you name your custom macro EditUndo, it will be used in place of the
built-in undo command attached to the Ctrl-Z keyboard shortcut.


--
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup


Bourgui

unread,
Sep 8, 2008, 5:08:01 PM9/8/08
to
Thank you Jay and Jonathan,

I had the same idea (except with documentproperties rather than bookmarks),
but I was hoping for a more 'elegant' solution - my users could well be
working with bookmarks or document properties themselves, in fact I know some
of them are.

Would there be a way of modifying the Undo stack, without clearing it
completely like 'UndoClear' does? This way I could simply remove the X number
of actions from it when at the end of my macro. Or is it possible to set the
Undo stack to 'not capture' while my macro is running?

Thanks!

Jonathan West

unread,
Sep 8, 2008, 5:23:04 PM9/8/08
to

"Bourgui" <Bou...@discussions.microsoft.com> wrote in message
news:552E70AD-4F94-4CD4...@microsoft.com...

> Thank you Jay and Jonathan,
>
> I had the same idea (except with documentproperties rather than
> bookmarks),
> but I was hoping for a more 'elegant' solution - my users could well be
> working with bookmarks or document properties themselves, in fact I know
> some
> of them are.
>
> Would there be a way of modifying the Undo stack, without clearing it
> completely like 'UndoClear' does?

No. the stack has to contain the last action (so it can undo it) or contain
nothing. You can't selectively undo the last-item-but-37 because the 37
subsequent actions mich mean that the text that was acted on isn;t there any
more.

> This way I could simply remove the X number
> of actions from it when at the end of my macro. Or is it possible to set
> the
> Undo stack to 'not capture' while my macro is running?

No, for the same reason.

Bourgui

unread,
Sep 8, 2008, 6:33:00 PM9/8/08
to
I see, it makes sense.

I'll see what I can come up with then using the first solution, making it
as not intrusive as possible.

Thanks to both of you!!

raud...@gmail.com

unread,
Mar 9, 2018, 2:48:30 AM3/9/18
to
Has there been any new developments on Undoing all Macro Action in a Word document?
0 new messages