Log in

View Full Version : Insert specific Powerpoint slide from Master



Adleano
09-12-2012, 03:31 AM
Hello all,

I am creating an automized powerpoint-report using VBA. Therefore I use Office 2010. Currently i am struggeling with a - hopefully small - problem.

I use a predifined Presentation as model. In this presentation I have a Master, a title-Master and a "Chart-Master".
Now I want to add a Slide using the "Chart-Master". But I donīt know how to get this Master.

Here is my call to add a new Slide using the "title-Master"
Set ppSliedeNeu = ppPres.Slides.Add(Index:=ppPres.Slides.count + 1, Layout:=ppLayoutTitle)


What I have to do to geht the "Chart-Master"? Do I have to name it specially, so I can use the Microsoft predefined layout properties? If so, which name I have to give the "ChartMaster"?

Many thanks and best regards

Adleano

John Wilson
09-14-2012, 06:51 AM
Do you mean your Master has a custom layout renamed to "Chart-Master"??

If you named it (Right click >> rename)

Sub insertpneu()
Dim pppres As Presentation
Dim osld As Slide
Dim ocust As CustomLayout
Set pppres = ActivePresentation
Set ocust = getLayout("Chart-Master") ' the name you used to rename
If Not ocust Is Nothing Then
Set osld = pppres.Slides.AddSlide(Index:=pppres.Slides.Count + 1, pCustomLayout:=ocust)
Else
MsgBox "That Layout does not exist"
End If
End Sub

Function getLayout(strname As String) As CustomLayout
For Each getLayout In ActivePresentation.Designs(1).SlideMaster.CustomLayouts
If getLayout.Name = strname Then Exit Function
Next
End Function

Adleano
10-15-2012, 12:56 AM
Hello John,

thanks a lot for the snippit. It works very good.
:bow:
Best regards and sorry for late reply.

Adleano