Font not being set


#1

I have a powerpoint presentation with many textframes with text already inside them. I am trying to add text to specific frame by first checking to see if the frame has more than 1 paragraph. If so then I attempt to use that paragraph and add my own text and change the font (name and size). If the frame only has 1 paragraph then I create a new paragraph. My code works fine if the paragraph doesn’t exist, however, if the paragraph exists then the text is added but the font stays the same (Times New Roman 24pt instead of Tahoma 9pt)

Code follows:

Dim shape As Shape = slide1.Shapes(8)
Dim para As Paragraph
Dim port As New Portion

'If there is only 1 paragraph create a new one
If shape.TextFrame.Paragraphs.Count < 2 Then
para = New Paragraph
shape.TextFrame.Paragraphs.Add(para)
Else
'Use the paragraph thats already there
para = shape.TextFrame.Paragraphs(1)
End If
port.FontItalic = False
port.FontShadow = False
port.FontColor = Color.Black
port.FontHeight = 9
port.FontIndex = 1
port.Text = “Some text”
para.Portions.Add(port)

I create the font by doing the following when I open the existing presentation:
Dim f As FontEntity = New FontEntity(pres, pres.Fonts(0))
f.FontName = “Tahoma”
f.CharSet = FontCharSet.ANSI_CHARSET
f.Family = FontFamily.DONTCARE
f.Pitch = FontPitch.DEFAULT_PITCH
f.Quality = FontQuality.PROOF_QUALITY
pres.Fonts.Add(f)

Thanks for any help
Marnitz


#2

Your code (at least from this post) is correct and works very well in my test app with any number of paragraphs.
Try to finnd differencies between this code and your real application.