I marked up a rectangular shape of text to be updated by inserting some marker text in the Alternative Text. I loop thru all my slides and shapes. When I find my shape, I replace the TextFrame.Text with my desired new text. Everything works and the text got changed to what I want except that Aspose unexpectedly modified the font size, color and spacing, etc. If users just change the TextFrame.Text, they do not expect the font size or other styles to be changed. Below is the few lines of code I have. Why does Aspose change the font size & styles? Did I do anything wrong or could there be potentially be a bug somewhere?
To partially fixed the problem, I had to changed the font size back to the original value before the update, by adding these two lines:
pshape.TextFrame.Paragraphs(0).Portions(0).FontHeight = 7
pshape.TextFrame.Paragraphs(1).Portions(0).FontHeight = 7
This is the code:
' loop thru each slide and each shape in a slide and change the text
Private Sub updateSlides(ByVal pres As Presentation)
For Each sl As Slide In pres.Slides
For Each sh As Shape In sl.Shapes
If sh.AlternativeText = "update_text" Then
updateText(sh)
End If
Next
Next
End Sub
'==============================================================
' replace the special marker within the TextFrame with desired new text
Private Sub updateText(ByVal pshape As Shape, ByVal QuarterEndDate as DateTime)
Dim textContent As String = pshape.TextFrame.Text
If textContent.Contains("@@as_of_date") Then
pshape.TextFrame.Text = pshape.TextFrame.Text.Replace("@@as_of_date", Format(QuarterEndDate, "MMMM d, yyyy"))
' I should not need these following lines to change the font size back to the original value
pshape.TextFrame.Paragrahps(0).FontHeight = 7
pshape.TextFrame.Paragrahps(0).FontHeight = 7
End If
End Sub