Hi,
I found a possible bug in PowerPoint 2013 (with all Updates).
To reproduce this do following.
- Open a new blank presentation.
- Add any chart on the first slide
- Now add any shape (e. g. Oval) inside the chart of 2). If you are moving the chart, the shape must be moved too.
- Select the inserted shape
Now if you run following code, you get an error ("Integer out of range. 1 is not in the valid range of 1 to 0.")
In debugger I can see that Selection.ShapeRange is empty, even though Selection.Type == ppSelectionShapes.
if (PowerPointApp.ActiveWindow.Selection.Type == MSPowerPoint.PpSelectionType.ppSelectionShapes) { MSPowerPoint.Shape shape = PowerPointApp.ActiveWindow.Selection.ShapeRange[1]; if (PowerPointApp.ActiveWindow.Selection.HasChildShapeRange) { shape = PowerPointApp.ActiveWindow.Selection.ChildShapeRange[1]; }
// Do something with shape
}
How can I get a reference to selected shape? I believe this is a Bug in PowerPoint.
Regards,
Daniel