Dear Romana,
First of all please accept my apologies for taking time.
Please use the code snippet below for accessing the picture frames and text frames. Remember that in PPTX, text frames are either part of place hodlers or part of autoshapes in shapes.
static void UpdatePowerpoint(string fReportID, string fPPTPath, string pptname)
{
string output_file_name = string.Empty;
string[] files = System.IO.Directory.GetFiles(fPPTPath);
string fileName = string.Empty;
//Get the Ptah of the pPt saved in Report folder
String PPTFullPath = fPPTPath + "\\" + pptname;
//Open the PPT
PresentationEx presnew = new PresentationEx(PPTFullPath);
//loop through all Slides to replace all images which have Alt Text
for (int j = 2; j <= presnew.Slides.Count; j++)
{
Aspose.Slides.Pptx.SlideEx slide = presnew.Slides[j-1];
Aspose.Slides.Pptx.ShapesEx shapes = slide.Shapes;
for (int i = 0; i < shapes.Count; i++)
{
Aspose.Slides.Pptx.ShapeEx shape = shapes[i];
//check if the shape is Picture
if (shape is PictureFrameEx)
{
Aspose.Slides.Pptx.PictureFrameEx pic = shape as PictureFrameEx;
//match d alternate text on image wid d image name read from xml file
if (pic.AlternativeText != null && pic.AlternativeText != "")
{
//get d absolute path of newpic
string str = fPPTPath + "\\" + pic.AlternativeText.ToString() + ".jpg";
str = fPPTPath + "\\Winter.jpg";
if (File.Exists(str))
{
//Adding Image to Picture frame
System.Drawing.Image img = (System.Drawing.Image)new Bitmap(str);
ImageEx imgx = pic.Presentation.Images.AddImage(img);
pic.PictureFormat.Picture.Image = imgx;
slide.SlideShowTransition.AdvanceOnClick = true;
}
}
}
else if (shape is AutoShapeEx )
{
AutoShapeEx ashp = (AutoShapeEx)shape;
if (ashp.AlternativeText == "Currency" && ashp.AlternativeText != "")
{
TextFrameEx tf = ashp.TextFrame;
// string CurrencyText = rmBL.GetLiteral("txtInputPrice");
string CurrencyText = "txtInputPrice";
String Currency = "USD";
tf.Text = CurrencyText + Currency;
tf.Paragraphs[0].Portions[0].FontBold = Aspose.Slides.Pptx.NullableBool.True;
tf.Paragraphs[0].Portions[0].FontHeight = 10;
tf.Paragraphs[0].Portions[0].FillFormat.SolidFillColor.Color = System.Drawing.Color.Black;
}
}
}
}
//Save the modified PPT
output_file_name = fPPTPath + "\\12" + pptname;
presnew.Write(output_file_name);
}
We are sorry for the delay and inconvenience that you might have experinced.
Mudassir Fayyaz
Support Developer
Aspose Sialkot Team
Contact Us Aspose - The .NET and Java Component Publisher
Keep in touch! We're on
Twitter and
Facebook