Hi,
Thank you for your e-mail. What I meant by performance issue is
I am trying to Extract charts from an excel and convert it into an image. I have a presentation contains Image. The ALT Text of the Image say Image_1. Now I am getting the Image_1 from Excel chart and replacing it by the Image itself. So Everytime when the program runs Images are updated automatically.
A probale way of solving my requirement.
Now with 1 image it works fine. But I have aroung 50 slides and 50 image :(. So what happens, the program stops working and it seems that the system hangs. The presentation file is around 2.5MB in size.
I don’t know whether there is any limitation or not.
I am not ablr to share the PPT for security reasons. Its PPT and not PPTX.
Here is the code which I used:
-------------------------------------------------------------
//load ProjectPPT
Presentation presnew = new Presentation(“C:\TMPOCTeast\Test.ppt”);
XmlDocument xDoc = new XmlDocument();
ArrayList arImage = new ArrayList();
xDoc.Load(“C:\TMPOCTeast\chartlist.xml”);
XmlNodeList xmlimage = xDoc.GetElementsByTagName(“image”);
XmlNodeList xmlImgName = xDoc.GetElementsByTagName(“name”);
int k = 0;
//Read from chartlist.xml file and store images name in Array object
foreach (XmlElement NewImg in xmlImgName)
{
arImage.Add(NewImg.InnerText);
k++;
}
for (int j = 1; j <= presnew.Slides.Count; j++)
{
Slide slide = presnew.GetSlideByPosition(j);
Shapes shapes = slide.Shapes;
for (int i = 0; i < shapes.Count; i++)
{
Shape shape = shapes[i];
//check if the shape is Picture
if (shape is PictureFrame)
{
PictureFrame pic = shape as PictureFrame;
for (int k1 = 0; k1 < k; k1++)
{
string newpic_name = arImage[k1].ToString();
//match d alternate text on image wid d image name read from xml file
if (pic.AlternativeText != null && pic.AlternativeText != “”&&pic.AlternativeText==newpic_name)
{
//get d absolute path of newpic
string str = “C:\TMPOCTeast\Image\” + arImage[k1].ToString();
Picture new_pic = new Picture(slide.Parent, str);
int old_pic_id = pic.PictureId,
new_pic_id = slide.Parent.Pictures.Add(new_pic);
pic.PictureId = new_pic_id;
}
}
// else continue;
}
}
}
//Save the modified PPT as Output.ppt
string output_file_name = @“C:\TMPOCTeast\Test.ppt”;
presnew.Write(output_file_name);
-------------------------------------------------------------
Regards,
Dibyendu