Reputation: 3802
I was trying to get a current selected object present in PPTX file for an VSTO addon.
I was using the below package for creating a chart,tables and text in slides.
using PowerPoint = Microsoft.Office.Interop.PowerPoint;
using Office = Microsoft.Office.Core;
I have a button present in the Ribben bar. Once the user clicks it I wanted to get the current selected object in any slide. How do I do this? Is there any way present in the interop
package.
Upvotes: 0
Views: 568
Reputation: 768
If you are selecting one or more shapes, you could do something like this
if (Globals.ThisAddIn.Application.ActiveWindow.Selection.ShapeRange.Count > 0)
{
//iterate over all the shapes selected by the user
foreach (PowerPoint.Shape shp in Globals.ThisAddIn.Application.ActiveWindow.Selection.ShapeRange)
{
if (shp.HasTable == Office.MsoTriState.msoTrue)
{
//Do something
}
if (shp.HasChart == Office.MsoTriState.msoTrue)
{
//Do something
}
if (shp.HasTextFrame == Office.MsoTriState.msoTrue)
{
//Do something
}
//or you could just return the shp object
}
}
Upvotes: 0