PDA

View Full Version : Need VBA to apply a Custom Layout in PowerPoint



rwc1023
06-04-2021, 06:39 AM
Hello experts! i have been battling with getting the right VBA to apply a custom layout to my slides. it is like pulling hair because I am totally new to VBA (still trying to learn it):banghead: so I hope someone who has done this or know can help out! Much appreciated.

1. I have hundreds of powerpoint decks that needed to switch to a new theme. I have the VBA created for that and now I need to use VBA to switch the custom layout of the slides. When I check the Layout area, there are like 20 different layouts from the standard template. See image attached. I need to change the First Slide of the deck to the "Title slide" layout (as shown on the layout collection), and the remaining slides to the "Title and Content" (as shown on the layout collection). I tried the codes for the first slide but it is not working...

Will someone please HELP??!! :hi:: pray2: I need to do it for the first slide and the remaining slides....THANK YOU! :friends:


Sub ChangeIntroSlideLayout()


ActivePresentation.Slides(1).Layout = ppLayoutTitleslide




End Sub

28570

John Wilson
06-05-2021, 08:49 AM
You are trying to use code from the 2003 version which no longer applies

Try this (ON A COPY!)


Sub apply_CL()
Dim L As Long
ActivePresentation.Slides(1).CustomLayout = ActivePresentation.SlideMaster.CustomLayouts(1)
For L = 2 To ActivePresentation.Slides.Count
ActivePresentation.Slides(L).CustomLayout = ActivePresentation.SlideMaster.CustomLayouts(2)
Next L
End Sub

rwc1023
06-05-2021, 06:56 PM
You are trying to use code from the 2003 version which no longer applies

Try this (ON A COPY!)


Sub apply_CL()
Dim L As Long
ActivePresentation.Slides(1).CustomLayout = ActivePresentation.SlideMaster.CustomLayouts(1)
For L = 2 To ActivePresentation.Slides.Count
ActivePresentation.Slides(L).CustomLayout = ActivePresentation.SlideMaster.CustomLayouts(2)
Next L
End Sub




Hi John! this worked like magic. thank you so much!!