VBA code to set two different font sizes in a textframe

D

Dale Fye

I'm using Access VBA to build a series of data driven slides, and want the
Title in one of the slides to contain a line of text that has font.size = 36,
and the font.size on the following like to 18).

The code I'm using right now looks like:
oShape.TextFrame.TextRange.Font.Size = 36
oShape.TextFrame.TextRange = "First Line" & vbcrlf & "Second line"

How can I modify this code to accomplish my goal?
 
D

David Marcovitz

I'm using Access VBA to build a series of data driven slides, and want the
Title in one of the slides to contain a line of text that has font.size = 36,
and the font.size on the following like to 18).

The code I'm using right now looks like:
oShape.TextFrame.TextRange.Font.Size = 36
oShape.TextFrame.TextRange = "First Line" & vbcrlf & "Second line"

How can I modify this code to accomplish my goal?

Off the top of my head, it would be something like:

OShape.TextFrame.TextRange.Paragraphs(2).Font.Size = 18
OShape.TextFrame.TextRange.Paragraphs(1).Font.Size = 36

I seem to recall that this can be a bit tricky in that sometimes changing
the last line affects other lines (which is why I did the last line first),
but I might be remembering.

--David
--
David M. Marcovitz
Author of _Powerful PowerPoint for Educators_
http://www.PowerfulPowerPoint.com/
Microsoft PowerPoint MVP
Associate Professor, Loyola University Maryland
 
M

mcnewsxp

I'm using Access VBA to build a series of data driven slides, and want the
Title in one of the slides to contain a line of text that has font.size = 36,
and the font.size on the following like to 18).

The code I'm using right now looks like:
oShape.TextFrame.TextRange.Font.Size = 36
oShape.TextFrame.TextRange = "First Line" & vbcrlf & "Second line"

How can I modify this code to accomplish my goal?

each textframe has only one fint.size property per rendering
 
J

John Wilson

Does this work Dale?
With ActivePresentation.Slides(1).Shapes(1).TextFrame.TextRange
..Text = "This is the text" & vbCrLf & "This is the other text"
..Lines(1).Font.Size = 36
..Lines(2).Font.Size = 18
End With
 
S

Steve Rindsberg

each textframe has only one fint.size property per rendering

That's technically correct but not relevant.

You can set the text font properties for a textframe.textrange to change all
of the text in the textframe, but you can also change the font properties of
each *character* in a text frame's text if you like.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top