How do you set the font?


#1

I’ve got a template powerpoint slide that I open, then replace some values. The template’s font starts out as Arial. After replacing some text, it ends up as Times New Roman. How can I set the text back to Arial? I tried:

myParagragh.Text.Format(“FontName=Arial”)

but I was just guessing as to what goes in the string parameter, and guessed wrong. Is this the correct command to use if the correct string parameter is used?

I posted a question to the thread http://www.aspose.com/forums/ShowPost.aspx?PostID=9805 which seemed to address this problem but it hasn’t gotten any response.


#2
Dear Tom,

At first replace your code:
For i = 0 To theParagragh.Portions.Count - 1
If theParagragh.Portions.Item(i).Text = "" Or _
theParagragh.Portions.Item(i).Text Is Nothing Or _
theParagragh.Portions.Item(i) Is Nothing Then
theParagragh.Portions.RemoveAt(i)
Else
BreakdownPortion(theParagragh.Portions.Item(i))
theParagragh.Text.Format("FontName=Arial")
End If
Next

with:
For i = 0 To theParagragh.Portions.Count - 1
If theParagragh.Portions.Item(i).Text.Length > 0 Then
BreakdownPortion(theParagragh.Portions.Item(i))
End If
Next

Text font can be set as:
theParagraph.Portions.Item(i).FontIndex = index

where index is zero-based index of font in the Presentation.Fonts collection.