We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Powerpoint replace and save issues

I am testing the v4.0.1 aspose slides for .net dll and have two issues. I am doing a search and replace for text contained across all slides. There doesnt seem to be a top level way to do this like in the aspose.word and aspose.cells product, so i am iterating through all the slides, textholders and shapes per a couple of forum postings i saw.

there are two issues i came across. the attached unit test project has unit tests for both ppt and pptx

1. ppt issue: when i search and replace text in ppt files, once the file is saved, the style and formatting gets screwed up. run the powerpoint_ppt unit test and then open up the randomly named ppt file under your test results out folder and compare it to the test.ppt that is included in the unit test project. you will see even on the first page, for example, that the merge field [b_officialname] is no longer in white text and centered.

2. pptx issue. when i search and replace text in ppt files, once the file is saved, the new file cannot be opened in office 2007. run the powerpoint_pptx unit test and then try and open up the randomly named pptx file under your test results out folder.


Aspose.Slides for .NET 4.0.1 introduces a new namespace Aspose.Slides.Util that provides a PresentationScanner class. This class provides static methods to extract all the text at Presentation as well as Slides level. An example is here:

(Note: Always use Portion object to access the text format)

Presentation pres = new Presentation("test.ppt");

ITextBox[] tb = PresentationScanner.GetAllTextBoxes(pres, false);

for (int i = 0; i < tb.Length;i++ )

foreach( Paragraph para in tb[i].Paragraphs )

foreach( Portion port in para.Portions )




Using code similar to this and the GetAllTextBoxes method seems to have solved my first issue with PPT files, but I still have the second issue. GetAllTextBoxes only supports passing in a Presentation class, but i cannot open up a PPTX file with that class. it throws an error saying that it thinks its a zip file or corrupted. The only alternative ive found that doesnt error out during runtime is code like this:

PresentationEx pres = new PresentationEx(inputName);
TextFrameEx[] textFrames = PresentationScanner.GetAllTextFrames(pres, true);
List<KeyValuePair<string, string>> fields = GetTemplateFields();
foreach (KeyValuePair<string, string> item in fields)
foreach (TextFrameEx textFrame in textFrames)
textFrame.Text = ReplaceString(textFrame.Text, "[" + item.Key + "]", item.Value, StringComparison.CurrentCultureIgnoreCase);

But the problem with this code is what i mentioned before, that the end result pptx file cannot be opened in office 2007. ideas?


Please use the Aspose.Slides for .NET version available here. If problem persists, please provide the source PPTX for investigation.