Carlo
Carlo

Reputation: 223

How to get the master layout slide name

I'm populating PowerPoint slides with data from an Excel spread sheet. At the moment, I'm accessing the slide using the page number:

Set mySlide = PowerPointApp.ActivePresentation.Slides(1)

Using the Master View option in the UI, you can rename the slide. How can I find the slide using that name?

Thanks,

Carlo.

Upvotes: 2

Views: 2263

Answers (3)

mehdi
mehdi

Reputation: 2953

ActivePresentation.Slides(i).Master.Design.Name

It is the name you see for the theme, in the master view for the slide.

layoutIndex = ActivePresentation.Slides(i).CustomLayout.Index

It is the current layout of the slide in the above theme.

ActivePresentation.Slides(i).Master.Design.Parent.CustomLayouts.Item(layoutIndex).Name

It is the layout name of the currently selected layout of the slide.

it is the VBA, what you can say :-).

Upvotes: 2

Carlo
Carlo

Reputation: 223

So, what I wanted was a way to uniquely identify a PPT slide through VBA. The problem is that I still need to be able to identify that slide if it is copied to another PPT document.

So, what I found I had to do was:

  • create a text box on each page and hard-code the text to be something like "Slide:Cover" or "Slide:QuarterlyResults", etc.
  • loop through each slide
  • find "Slide:" and strip it out to get the page title. That way, if the slide is copied to another PPT document, the name goes with it.
  • create a Dictionary that uses the Slide.SlideID as the key and the page title as the value.

Then what I do is loop through the slides, get the SlideID, use the Dictionary to get the page title and use a Select statement to map to the proper method to process the slide.

Yeah, I know... it's an icky hack, but it's the only way I could think of doing it.

Thanks for you help,

Carlo.

Upvotes: 0

Chrismas007
Chrismas007

Reputation: 6105

Using the Slide.Name property will define the name of the slide and allow it to be called using:

ActivePresentation.Slides("Name")

per the MSDN

Upvotes: 0

Related Questions