Working with text in PowerPoint 2007 (VBA)
How can I set a font to the Heading or Body font style?
You can manually select any font you like for text, or you can select the font associated with the current font theme for Headings or Body. For example, by default, in a new presentation, the headings (titles) will be set to "Calibri (Headings)" rather than just Calibri.
This tells you that if you change to a different Font theme, the text will take on whatever font is assigned to Headings for that theme
But what if you want to assign the Headings or Body style to some text programmatically? Here's the trick (as yet undocumented; thanks to our friends at Microsoft for supplying this information):
To assign a Headings (major) or Body (minor) font style to text, you change the font name to this:
"+" & FontType & "-" & FontLang
FontType:
- Major (Headings) = "mj"
- Minor (Body) = "mn"
FontLang:
- Latin = "lt"
- Complex Scripts = "cs"
- East Asian = "ea"
So to change all of the selected shapes on a slide to the Major/Headings typeface for Latin text:
Sub Example() Dim osh As Shape For Each osh In ActiveWindow.Selection.ShapeRange With osh With .TextFrame.TextRange .Font.Name = "+mj-lt" End With End With Next End Sub
After selecting some shapes that include text and running this, go to the Design tab and change the Fonts themes. Note that each of the changed text box fonts will change to as you change font themes.