Nowshad Shaik
Nowshad Shaik

Reputation: 1

Applying layout to a slide from specific Master

I need to apply a specific layout to a slide from a specific master.

Suppose I have two master templates in the deck and I want to apply "Title Only" layout from the second master.

The code is running but layout is not changed.

ActivePresentation.Slides(11).Layout = ppLayoutTitleOnly
ActivePresentation.Slides(11).Select
Application.CommandBars.ExecuteMso ("SlideReset")

Two screenshots.

enter image description here

enter image description here

Upvotes: 0

Views: 732

Answers (1)

John Korchok
John Korchok

Reputation: 4923

The .Layout property is only useful for applying default Microsoft layouts. In most customized presentations such as yours, you can't count on any of those layouts being that standardized. Instead, use the .CustomLayout property, which, despite its name, actually applies any layout, custom or not.

The syntax for accessing a slide master is non-intuitive:

Sub PickSlideLayout()
  ActivePresentation.Slides(1).CustomLayout = ActivePresentation.Designs(2).SlideMaster.CustomLayouts(6)
End Sub

.Designs(2) gets you the second slide master. .CustomLayouts(6) gets the Title Only layout in a standard presentation. CustomLayouts doesn't take a string, so you can't use the layout name. Instead you have to refer to the layout number or index.

Upvotes: 2

Related Questions