I have the following VBA code to create a new PowerPoint slide:
longSlideCount = ActivePresentation.Slides.Count
With ActivePresentation.Slides
Set slideObject = .Add(longSlideCount + 1, ppLayoutTitle)
End With
...which inserts a new slide of type 'ppLayoutTitle', but I am wondering if it is possible to create a custom layout in the 'Slide Master View' and then insert that particular slide template into the presentation?
Thanks in advance!!!
All your custom layouts can be accessed via VBA through the
CustomLayoutscollection of theSlideMasterproperty of aPresentationobject. When you create a custom layout, give it a meaningful name. Then you can fetch it from theCustomLayoutscollection. It appears that Microsoft didn't implement lookup by name, so you will have to iterate through the collection to find theCustomLayoutobject with the right name.Once you have a reference to the desired
CustomLayoutobject, you use theAddSlidemethod of theSlidescollection, which takes aCustomLayoutobject as the second arguments (as opposed toSlides.Add, which you used in your question, and which takes aPpSlideLayoutenumeration value).Below is a helper method for fetching a custom layout by name, and example of using it as you wanted: