Share via

Undo / Redo problem with Powerpoint

Anonymous
2012-05-18T12:19:32+00:00

Im creating a powerpoint addin using vsto 3.0 for office 2007 powerpoint. My problem is that when im adding anything like slides, shapes, textboxes etc they dont add into the undo/redo stack due to which ctrl+z clears off everything to the first point and its a major show stopper.

Microsoft 365 and Office | PowerPoint | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

Anonymous
2012-05-18T12:48:21+00:00

In VBA... in 2010, you can use Application.StartNewUndoEntry to start a new entry in the undo stack.  But in 2007 we have to use this work around:

If you do something using Application.Commandbars.ExceuteMso("...") then a new entry is created in the undo stack.  If you don't want that action to appear in the undo stack, you can undo it with

    Application.Commandbars.ExceuteMso("Undo")

A new stack entry will then be left for whatever the code does after calling the undo.

To get the string to include within the brackets, add a command to the QAT, then in the customize the QAT window, hover over it and you will see the string in brackets.

Which command to use will depend on what you are doing - obviously the command button has to be enabled to be able to press it.

So if you have a shape selected, you could use:

            Application.CommandBars.ExecuteMso ("ObjectFlipHorizontal")

            Application.CommandBars.ExecuteMso ("Undo")

but if you have text selected, you could use

            Application.CommandBars.ExecuteMso ("Bold")

            Application.CommandBars.ExecuteMso ("Undo")

You can test what is selected with If ActiveWindow.Selection.Type = .... Then

Alternatively, you can have your code create a shape and select it, flip and undo, then delete it.

Hope that makes sense.

Cheers

Rich

Was this answer helpful?

0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Anonymous
    2012-05-18T13:02:05+00:00

    That's clever Rich!

    Was this answer helpful?

    0 comments No comments