Presentation.ApplyTemplate2 方法 (PowerPoint)

將設計範本和主題變體套用至簡報。

語法

expressionApplyTemplate2 (FileName,Variant)

表達 代表 Presentation 物件的變數。

參數

名稱 必要/選用 資料類型 描述
FileName 必要 String 會指定簡報設計範本的名稱。
Variant 必要 String 指定要套用的變體名稱。
FileName 必要 String
Variant 必要 String
VariantGUID 必要 String

傳回值

無效

範例

本範例會開啟主題檔案、取得主題中第三個變體的識別碼,並將它套用至簡報。

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.ApplyTemplate2 path, variantID

End Sub

支援和意見反應

有關於 Office VBA 或這份文件的問題或意見反應嗎? 如需取得支援服務並提供意見反應的相關指導,請參閱 Office VBA 支援與意見反應