Free Support Forum -

How to write in a shape?

I have attached a ppt.

I have a top shape with Alternate Text as "ReportHeaderLine2"
Currently the text is Active NPS Scorecard – Q1 2012…
How do i change this by code?
I want to access the shape using alternate text and then change the text…

Hi Pankaj,

I have observed the requirements shared by you. Please use the following code snippet to serve the purpose.

public static ShapeEx FindShape(SlideEx slide, string alttext)
//Iterating through all shapes inside the slide
for (int i = 0; i < slide.Shapes.Count; i++)
//If the alternative text of the slide matches with the required one then
//return the shape
if (slide.Shapes[i].AlternativeText.CompareTo(alttext) == 0)
return slide.Shapes[i];
return null;

public static void ChangeText()
PresentationEx pres = new PresentationEx(“D:\Aspose Data\Pankaj.pptx”);
ShapeEx shape = FindShape(pres.Slides[0], “ReportHeaderLine2”);
if (shape is AutoShapeEx)
AutoShapeEx ashp = (AutoShapeEx)shape;
TextFrameEx txtFrm = ashp.TextFrame;
if (txtFrm != null && txtFrm.Text != “”)
ParagraphEx para = txtFrm.Paragraphs[0];
PortionEx portion = para.Portions[0];
portion.Text = “New Text Added”;

pres.Write(“D:\Aspose Data\Pankaj2.pptx”);


Many Thanks,
									Hi Mudasir,<br><br>I set AltText for shap or place holder, but I still can't get the value, Alternativetext I got always empty. Could you send me the template working with your example code for me can try?<br><br>I need the solution can detect object uniquely. I'm thinking of defining AltText for them. I hope it will work.<br><br>Thank you,<br>GN<br><br><br>

Hi GN,

I feel you may be adding the alternative text in the title. You need to add that in description field. Please visit this thread link for your kind reference.

Many Thanks,