1

I have 2 shapes: A and B in a PowerPoint.Slide. I used this tutorial to catch shape events including removing or creating shapes.

When I got notified about deleting shape A, I will delete shape B at the same time. PowerPoint will understand deleting shape A, and deleting shape B are 2 separate actions. Therefore, after undo, the shape B will be shown, but not the shape A. However, I want the shape A will be shown as well. How can I do that?

I experiment by deleting shape A, and shape B programmatically at once:

shapeA.delete(); shapeB.delete();

and now if I undo, PowerPoint will recover 2 shapes A and B for me. It's what I need.

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
chipbk10
  • 5,783
  • 12
  • 49
  • 85

1 Answers1

0

What I am thinking right now is trigger undo manually from code.

If the user undos, the shape B is shown. At that time, I will check on the existence of the shape A (by finding via Shape.Id or Shape.Name in PowerPoint). If shape A does not exist, we will undo manually.

PowerPoint.Shape shapeA = shapes[nameShapeA];
if (shapeA != null)
{

   Application.CommandBars.ExecuteMso("Undo");
}

Any other workarounds?

chipbk10
  • 5,783
  • 12
  • 49
  • 85