SlideRange.ApplyTemplate2 method (PowerPoint)
Applies a design template and theme variant to the slide range.
Syntax
expression. ApplyTemplate2
(FileName, Variant)
expression A variable that represents a SlideRange object.
Parameters
Name | Required/Optional | Data type | Description |
---|---|---|---|
FileName | Required | String | Specifies the name of the design template. |
Variant | Required | String | Specifies the name of the variant to apply. |
FileName | Required | String | |
Variant | Required | String | |
VariantGUID | Required | String |
Return value
VOID
Example
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
Support and feedback
Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for