Need Code for a PowerPoint Macro to Set Font Size

V

vikr

I need a PowerPoint macro. Say my cursor is in a text box. I need a
macro to :

- select all text
- make it Times 9 point

I tried a couple of ways to do this, but I haven't found the correct
way to do this yet.

Can anyone post the correct PowerPoint macro code to do this? Thanks
very much in advance.
 
D

David M. Marcovitz

Something like this ought to work. Just beware, I didn't put in any error
checking so you'll get an error if nothing is selected and if whatever is
selected doesn't have a TextFrame.
--David

--
David M. Marcovitz
Microsoft PowerPoint MVP
Director of Graduate Programs in Educational Technology
Loyola College in Maryland
Author of _Powerful PowerPoint for Educators_
http://www.PowerfulPowerPoint.com/

(e-mail address removed) wrote in @u30g2000hsc.googlegroups.com:
 
D

David M. Marcovitz

Something like this ought to work. Just beware, I didn't put in any
error checking so you'll get an error if nothing is selected and if
whatever is selected doesn't have a TextFrame.
--David

It would help if I pasted the code into the message...

Sub Times9()
ActiveWindow.Selection.ShapeRange(1).Select
With ActiveWindow.Selection.ShapeRange.TextFrame.TextRange
.Font.Name = "TimesNewRoman"
.Font.Size = 9
End With
End Sub

--
David M. Marcovitz
Microsoft PowerPoint MVP
Director of Graduate Programs in Educational Technology
Loyola College in Maryland
Author of _Powerful PowerPoint for Educators_
http://www.PowerfulPowerPoint.com/
 
V

Vik Rubenfeld

David M. Marcovitz said:
It would help if I pasted the code into the message...

Sub Times9()
ActiveWindow.Selection.ShapeRange(1).Select
With ActiveWindow.Selection.ShapeRange.TextFrame.TextRange
.Font.Name = "TimesNewRoman"
.Font.Size = 9
End With
End Sub

With a very slight change, it works:

Sub Times9()
ActiveWindow.Selection.ShapeRange(1).Select
With ActiveWindow.Selection.ShapeRange.TextFrame.TextRange
.Font.Name = "Times New Roman"
.Font.Size = 9
End With
End Sub


Thanks very much, David!


-Vik
 
D

David M. Marcovitz

With a very slight change, it works:

Sub Times9()
ActiveWindow.Selection.ShapeRange(1).Select
With ActiveWindow.Selection.ShapeRange.TextFrame.TextRange
.Font.Name = "Times New Roman"
.Font.Size = 9
End With
End Sub


Thanks very much, David!


-Vik

Ah. Great. When I tested it, the font size got too small for my eyes to
actually read, so I didn't even notice that the font didn't change. At 9
point size, all fonts look just about the same to me. I'm glad you knew
enough to add the spaces and make it work. And thanks for getting back to
us to let us know.
--David

--
David M. Marcovitz
Microsoft PowerPoint MVP
Director of Graduate Programs in Educational Technology
Loyola College in Maryland
Author of _Powerful PowerPoint for Educators_
http://www.PowerfulPowerPoint.com/
 

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