I need you: I should insert a dynamic index (which also updates the page number associated with the title) in my PowerPoint presentation.
I have searched online but have not found any solution; the only one approaching uses a VBA macro (the code below) which is based on the hyper-textual link: when the macro is launched it updates the page number in the index but subsequently the link is deleted and therefore it is necessary reinsert it manually.
Is there any way to automate the process? Thank you.
Sub TableOfContentUpdater()
Dim pTableOfContent As Slide
Set pTableOfContent = ActivePresentation.Slides(2)
For Each pHyperLink In pTableOfContent.Hyperlinks
Dim pLinkNumber As String
Dim pLinkedSlide As Slide
pLinkNumber = Left(pHyperLink.SubAddress, InStr(pHyperLink.SubAddress, ",") - 1)
pHyperLink.TextToDisplay = ActivePresentation.Slides.FindBySlideID(CLng(pLinkNumber)).SlideIndex
Next pHyperLink
End Sub
I've developed a script for generating an entire table of contents in PowerPoint from scratch that loops through all of the slides and assembles their header text along with their relative slide number and applies the appropriate hyperlink. Here is the code:
The preceding code produces the following result:
Combining this example with your usage case, we can loop through and map the hyperlink names, slide indexes, and destinations in array lists. Then, we can use the arrays to update the links appropriately.
Here is the example code:
When applied to the spreadsheet that was created above, this is the result:
