共用方式為


Application.OpenThemeFile 方法 (PowerPoint)

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

語法

expressionOpenThemeFile (主題檔案名稱)

expression 代表 Application 物件的變數。

參數

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

傳回值

Theme

範例

這個範例會打開一個主題檔案,取得主題中第三個變體的 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 支援與意見反應