Consulting

Results 1 to 3 of 3

Thread: Need VBA to apply a Custom Layout in PowerPoint

  1. #1
    VBAX Regular
    Joined
    Jun 2021
    Posts
    17
    Location

    Need VBA to apply a Custom Layout in PowerPoint

    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) 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??!! I need to do it for the first slide and the remaining slides....THANK YOU!


    Sub ChangeIntroSlideLayout()


    ActivePresentation.Slides(1).Layout = ppLayoutTitleslide




    End Sub

    standard layouts.jpg

  2. #2
    VBAX Master
    Joined
    Feb 2007
    Posts
    2,093
    Location
    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
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials
    http://www.pptalchemy.co.uk/powerpoi...tutorials.html

  3. #3
    VBAX Regular
    Joined
    Jun 2021
    Posts
    17
    Location

    Cool

    Quote Originally Posted by John Wilson View Post
    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!!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •