Free Support Forum - aspose.com

Get Slide Title Text for Each Slide - Aspose.Slides .NET

I want to get the title of each slide. I have been testing with the code below.

However, it only returns the type of each Shape, not the actual text that is in the Shape.


//Instantiate a PresentationEx class that represents the PPTX file
PresentationEx pres = new PresentationEx(tbPPTpath.Text);
int iSlideCount = pres.Slides.Count;
for (int ind = 0; ind < iSlideCount; ind++)
{
//Access each slide
SlideEx sld = pres.Slides[ind];
pres.Slides[ind].Name.ToString();

ShapesEx curShapes = sld.Shapes;
for (int indShapes = 0; indShapes < curShapes.Count; indShapes++)
{
if (curShapes[indShapes].IsTextHolder && !String.IsNullOrEmpty(curShapes[indShapes].Name))
{
lbTitles.Items.Add("Slide " + (ind + 1).ToString() + ": " + curShapes[indShapes].Name.ToString());
}
}

lblStatus.Text = "Saving Slide " + (ind + 1).ToString() + " of " + iSlideCount.ToString();
Application.DoEvents();

It looks like I figured it out myself.

I posted my code below, if anyone wants to refer to it.

Thanks!

//Instantiate a PresentationEx class that represents the PPTX file
PresentationEx pres = new PresentationEx(tbPPTpath.Text);
int iSlideCount = pres.Slides.Count;
for (int ind = 0; ind < iSlideCount; ind++)
{
//Access each slide
SlideEx sld = pres.Slides[ind];

foreach (ShapeEx shp in sld.Shapes)
{
string sTitleText = null;
string sTitleType = null;
try
{
sTitleText = ((AutoShapeEx)shp).TextFrame.Text.ToString();
sTitleType = ((AutoShapeEx)shp).Name.ToString();
}
catch (Exception ex)
{ }

if (!String.IsNullOrEmpty(sTitleText))
{

if (shp.IsTextHolder && sTitleType.Contains(“Title”))
{
lbTitles.Items.Add("Slide " + (ind + 1).ToString() + ": " + sTitleText);
}
else if (shp.Placeholder != null && sTitleType.Contains(“Title”))
{

lbTitles.Items.Add(((AutoShapeEx)shp).TextFrame.Text);
}
}
}

Hi John,

It's really great to listen that you have managed to figure out the requirements your self. Please share if I may be of any further to you in this regard.

Many Thanks,