Slide.ApplyTemplate2 方法 (PowerPoint)

将设计模板和主题变体应用于幻灯片。

语法

expressionApplyTemplate2 (FileName,Variant)

表达 一个代表 Slide 对象的变量。

参数

名称 必需/可选 数据类型 说明
FileName 必需 String 指定设计模板的名称。
Variant 必需 字符串 指定要应用的变体的名称。
FileName 必需 字符串
Variant 必需 字符串
VariantGUID 必需 字符串

返回值

无效

示例

本示例打开一个主题文件,获取主题中第三个变体的 ID,并将其应用于演示文稿中的第一张幻灯片。

Sub ChangeThemeVariant()

    Dim name As String
    Dim path As String
    Dim variantID As String
    
    ' Get the name of the active theme family.
    name = ActivePresentation.TemplateName

    ' You need access to the Theme Family in order to access the variants.
    path = "C:\Program Files (x86)\Microsoft Office\Document Themes 15\" & _
        ActivePresentation.TemplateName & ".thmx"

    ' Get the variant ID of the third Variant
    ' and apply that variant to the presentation.
    variantID = PowerPoint.Application.OpenThemeFile(path).ThemeVariants(3).Id
    ActivePresentation.Slides(1).ApplyTemplate2 path, variantID

End Sub

支持和反馈

有关于 Office VBA 或本文档的疑问或反馈? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。