I've set up a macro that copy/pastes graphs and tables from a spreadsheet to specific slides in a pre-existing PowerPoint presentation using excel VBA. In the code, I have to specify the exact slide number to copy the excel graph to (done 100+ times).
The issue is that when slides are added/deleted from the presentation in the future, the slide numbers will change and I will have to go through the code and manually update each slide reference.
I'm looking for a way to name slides in PowerPoint then use those names in my excel vba code? Eliminating the risk of slides being added/deleted later on (which will definitely happen).
This post is similar in concept( vba powerpoint select a slide by name), but I can't seem to get it working using the excel vba.
An excerpt of the code I'm using to paste a graph is below. Instead of referencing slide 54, I'd rather use a named slide like "Performance":
Set oPPT = GetObject(, "PowerPoint.Application")
Set presUpdate = oPPT.Presentations("Presentation Name")
With presUpdate.Slides(54)
.Shapes.PasteSpecial(DataType:=xlBitmap).Select
.Shapes("Picture 1").Left = 34.01559
.Shapes("Picture 1").Top = 96.36512
End With
Thanks