OfficeTips Home || VBA Section || General Section || Download Section || Privacy Policy

Understanding Custom Layouts

First there was a slide master with a title master till PPT 2002. PPT 2002 introduced the concept of multiple masters - Designs. Each design contained a slide master and possibly a title master. Several designs could be stored within a presentation. This is discussed in detail in -  Multiple masters and how to access them. PowerPoint 2007 introduces a new concept - Custom Layouts. With it you can define any number of your own custom layouts associated with a slide master. Each design will contain one and only one slide master. But the slide master can contain several custom layouts which can be fully customized. Custom layouts inherit the slide masters properties like background, color etc. But these can be overidden. Let see how we can enumerate this information.

 

Sub EnumCustomLayouts()
Dim oDesign As Design
Dim oCL As CustomLayout
Dim lngLayoutCount As Long
Dim I As Integer
For Each oDesign In ActivePresentation.Designs
    lngLayoutCount = oDesign.SlideMaster.CustomLayouts.Count
    Debug.Print "Total number of custom layouts in design " & Chr(34) & _
oDesign.Name & Chr(34) & ": " & lngLayoutCount
    'Enumerate all the available layouts 
For I = 1 To lngLayoutCount
        Set oCL = oDesign.SlideMaster.CustomLayouts(I)
        Debug.Print "Name of layout: " & oCL.Name
    Next
Next
End Sub

Think of a CustomLayout object as just an another slide and you can manipulate it just the same way. To assign a background picture fill to 1st layout of the 1st design in the presentation

 
Sub AssignCustomBGTo1stLayout()
With ActivePresentation.Designs(1).SlideMaster.CustomLayouts(1)
    'The layout will inherit the background from it's parent - slide master - so override it.
    .FollowMasterBackground = False
    With .Background.Fill
        .UserPicture ("C:\Workarea\Documents\My Pictures\GaryGoh_A_1600x1200.jpg")
        .Visible = True
    End With
End With
End Sub

 

So how does one determine which layout is being used by a slide? Slides in 2007 have a CustomLayout object associated with them. You can access them like this:

 

ActivePresentation.Slides(1).CustomLayout.Index


The Index represents the index of the custom layout within the parent design.

To assign a custom layout is equally straightforward. To assign the 4th custom layout to the slide, use -

  ActivePresentation.Slides(1).CustomLayout =ActivePresentation.Designs(1).SlideMaster.CustomLayouts(4)
    
    

 

 

Copyright 1999-2012 (c) Shyam Pillai. All rights reserved.