Search code examples
vbapowerpointpowerpoint-2016

"create new theme font" in powerpoint slide master using vba


in powerpoint's slide master view, there is a "customize fonts" option which opens a window called "create new theme fonts". using that, one can set default heading/body fonts for latin/complex scripts. what is the equivalent vba code for this? thanks in advance.


Solution

  • I believe you're looking for the

    • Master.TextStyles property:

      Returns a TextStyles collection that represents three text styles — title text, body text, and default text — for the specified slide master.

    • PpTextStyleType Enumeration, specifically ppBodyStyle and ppTitleStyle.

    Modifying the code example provided under the Master.TextStyles property:

    Sub CustomizeFonts()
        Dim i As Integer
    
        With ActivePresentation.SlideMaster.TextStyles(ppBodyStyle)
            For i = 1 To .Levels.Count
                With .Levels(i).Font
                    .Name = "Garamond"
                End With
            Next i
        End With
    
    End Sub
    

    And something similar to modify the heading, replacing ppBodyStyle with ppTitleStyle.