Editing a slide loses formatting

Hi,

I have some methods that will replace text in slides using Aspose.Slides. The resulting presentation, however, loses the formatting on the edited slide. For example, a TextHolder that is formatted red in the source PPT becomes black (the default color) when it's text is replaced. Likewise, if I edit text in a slide that contains bulletted text (with sub-bullets) all of the text changes to the default size and color and all bullets are set to the highest level (no sub-bullets).

Below is one set of methods I use:

protected void FindAndReplaceText(Aspose.Slides.Presentation presentation, Aspose.Slides.Slide slide, string findText, string replaceText)
{
for (int i = 0; i < slide.Placeholders.Count; i++)
{
TextHolder th = slide.Placeholders[i] as TextHolder;
if (th != null)
{
foreach (Paragraph para in th.Paragraphs)
{
foreach (Portion portion in para.Portions)
{
portion.Text = ReplaceText(portion.Text, findText, replaceText);
}
}
}
}

foreach (Shape shape in slide.Shapes)
{
if (shape is OleObjectFrame)
{
break;
}
if (shape.IsTextHolder)
{
shape.TextFrame.Text = ReplaceText(shape.TextFrame.Text, findText, replaceText);
}
}
}

protected string ReplaceText(string sourceText, string findText, string replaceText)
{
int pos = sourceText.IndexOf(findText);
if (pos >= 0)
{
return sourceText.Replace(findText, replaceText);
}
return sourceText;
}

Thanks,

Dave

Dear Dave,

Thanks for considering Aspose.Slides

Change this line of your code

shape.TextFrame.Text = ReplaceText(shape.TextFrame.Text, findText, replaceText);

into like this

shape.TextFrame.Paragraphs[0].Portions[0].Text = 
    ReplaceText(shape.TextFrame.Text, findText, replaceText);

Brilliant! That did it. Thanks.