Reputation: 173
I am looking to rename all the slides in several presentations so that I can easily identify them. I will use them to build other presentations and need a way to identify if a slide came from a certain previous presentation. When I try to cycle through the slides, I get a read-only error when trying to rename the slide. How do I access and set the name? the sub fails when I try to change the 'name' property. Many thanks!
Sub EverySlideInPresentation1234(oPres As Presentation) ' Performs some operation on every slide in the currently active presentation
Dim oSl As slide
For Each oSl In oPres.Slides
oSl.Name = (("updatePort: " & Now()))
Next oSl
End Sub
Upvotes: 0
Views: 306
Reputation: 14809
I was able to repro this. The problem is that Now() returns date + hh:mm:ss AM|PM but there's way less than one second between the time you rename the first slide and the next, so you end up giving ... trying to give ... multiple slides the same name. PowerPoint doesn't allow that.
Use something like this to make the slide name unique:
oSl.Name = (("updatePort: " & Now())) & " " & oSl.SlideIndex
Or use Tags to store the data on the slide itself rather than using the name. Each slide could have a tag with the same value:
oSl.Tags.Add "UpdateTag", "updatePort: " & Now()
There's more info about using Tags on a PowerPoint FAQ site that I maintain, here:
Working with Tags (and a bit about Functions) http://www.pptfaq.com/FAQ00815_Working_with_Tags_-and_a_bit_about_Functions-.htm
Upvotes: 2