Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to detect Theme fonts in Powerpoint 2007 VBA?

Does anyone know how to detect the use of Theme fonts in Powerpoint 2007 slide objects using VBA? If one looks at Shape.TextFrame.TextRange.Font.Name the font name appears as simple name (ex: "Arial") whether or not the font was assigned as a fixed name or a Theme name (subject to change with the document theme). I don't see any other property in the Object Model that would flag the name as tied to a theme (such as ObjectThemeColor for colors).

Thanks!

like image 522
Sam Russo Avatar asked Nov 14 '22 14:11

Sam Russo


1 Answers

There is no direct method (that I know of), however you can check with an If/Then:

Sub checkthemeFont()
    Dim s As Shape
    Set s = ActivePresentation.Slides(1).Shapes(1)
    Dim f As Font
    Set f = s.TextFrame.TextRange.Font

    Dim themeFonts As themeFonts
    Dim majorFont As ThemeFont

    Set themeFonts = ActivePresentation.SlideMaster.Theme.ThemeFontScheme.MajorFont
    Set majorFont = themeFonts(msoThemeLatin)

    If f.Name = majorFont Then
        Debug.Print f.Name
    End If
End Sub
like image 146
Todd Main Avatar answered Dec 23 '22 15:12

Todd Main