Table of contents
TOC
折叠目录
展开目录

SlideRange.ApplyTemplate2 方法 (PowerPoint)SlideRange.ApplyTemplate2 Method (PowerPoint)

office 365 dev account|上次更新日期: 2018/3/13
|
2 参与人员

将一个设计模板和主题变体应用于幻灯片范围。Applies a design template and theme variant to the slide range.

语法Syntax

表达式ApplyTemplate2(文件名__变体)expression. ApplyTemplate2(FileName,Variant)

表达式_一个表示一个SlideRange对象的变量。_expression A variable that represents a SlideRange object.

参数Parameters

名称Name必需/可选Required/Optional数据类型Data type说明Description
文件名FileName必需RequiredStringString指定设计模板的名称。Specifies the name of the design template.
VariantVariant必需RequiredStringString指定应用的变量的名称。Specifies the name of the variant to apply.
文件名FileName必需RequiredSTRINGSTRING
VariantVariant必需RequiredSTRINGSTRING
VariantGUIDVariantGUID必需RequiredSTRINGSTRING

返回值Return value

VOIDVOID

示例Example

本示例打开一个主题文件、 获取主题中,第二个变量的 ID 并将其应用于演示文稿中的幻灯片。This example opens a theme file, gets the ID of the second variant in the theme, and applies it to the slides in the presentation.

Sub ChangeThemeVariant()

    Dim name As String
    Dim path As String
    Dim variantID As String
    Dim pptSlideRange As SlideRange

    ' 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 second Variant
    variantID = PowerPoint.Application.OpenThemeFile(path).ThemeVariants(2).Id

    ' Apply that variant to the range of slides.
    Set pptSlideRange = ActivePresentation.Slides.Range
    pptSlideRange.ApplyTemplate2 path, variantID

End Sub
© 2018 Microsoft