OfficeTips Home || VBA Section || General Section || Download Section || Privacy Policy |
Understanding the Designs Object |
|
PowerPoint 2002 introduces something that has been requested for a long time - support for multiple templates within the same presentation. Time to do away with earlier workarounds to simulate the same in 97/2000. With the introduction of multiple masters, how does one access the multiple templates? The new Designs collection helps you to iterate thru each template within the presentation and the Design object stores information about the template. A Design object consists of a slide master and/or a title master. The Designs collection will always consist of one Design object having a slide master.
Note: PowerPoint 2007 introduces the new CustomLayouts object which changes the implementation of masters in PowerPoint 2007 - Understanding Custom Layouts.
'An example to enumerate the Designs available in the presentation. Sub EnumDesigns()
Dim lCtrA As Integer
Dim oPres As Presentation Set oPres = ActivePresentation With oPres Debug.Print "Number of applied templates: " & .Designs.Count For lCtrA = 1 To .Designs.Count Debug.Print "Template Design name: " & .Designs(lCtrA).Name Debug.Print vbTab & "Slide master name: " & .Designs(lCtrA).SlideMaster.Name If .Designs(lCtrA).HasTitleMaster Then Debug.Print vbTab & "Title master name: " & .Designs(lCtrA).TitleMaster.Name Else Debug.Print vbTab & "No Title master present" End If Next lCtrA End With End Sub |
Designs can be added in one of the following ways:
Add method: A named design can be added by the Add method. The name of the design should be unique. This adds a design with a default slide master into the collection. The index argument specifies the location that the design should be placed within the collection. If omitted it is always placed at the end. You can use the AddTitleMaster method to add a title master to this design.
Sub AddADesign() ActivePresentation.Designs.Add DesignName:="ABlankDesign", Index:=1 ActivePresentation.Designs(1).AddTitleMaster End Sub |
Clone method: They can be cloned using the clone method. Cloning refers to the process of creating a copy of an already existing design in the Designs collection.
Sub CloneADesign()
Dim CloneDesign As Design With ActivePresentation Set CloneDesign = .Designs.Clone(.Designs(1)) CloneDesign.Name = "Dolly" End With End Sub |
Load Method: This method is used to insert an external template file (*.pot) into the designs collection. Since no index argument is provide in the example below this design gets added to the end of the collection.
Sub LoadADesign() ActivePresentation.Designs.Load "C:\Templates\Cute.pot" End Sub |
Copyright 1999-2022 (c) Shyam Pillai. All rights reserved.