如何在Powerpoint 2007 VBA中检测主题字体?

Sam*_*sso 5 powerpoint vba ms-office

有谁知道如何使用 VBA 检测 Powerpoint 2007 幻灯片对象中主题字体的使用?如果查看Shape.TextFrame.TextRange.Font.Name字体名称显示为简单名称(例如:“Arial”),则无论该字体是否被分配为固定名称或主题名称(可能会随文档主题而更改)。我在对象模型中没有看到任何其他属性将名称标记为与主题相关(例如ObjectThemeColor颜色)。

谢谢!

Tod*_*ain 1

没有直接的方法(据我所知),但是您可以使用 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
Run Code Online (Sandbox Code Playgroud)