共用方式為


PowerPoint) (Application.OpenThemeFile 方法

開啟指定的主題檔案 (*thmx) 。

語法

expressionOpenThemeFile (themeFileName)

expression 代表 Application 物件的變數。

參數

名稱 必要/選用 資料類型 描述
themeFileName 必要 字串 要開啟的主題檔案 (*.thmx) 路徑。
themeFileName 必要 字串

傳回值

Theme

範例

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

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 支援與意見反應