How to get links between PowerPoint slides in a presentation

I am looking for a way to read links between slides in one PowerPoint presentation. I need to open a PowerPoint file and get all the slides for the links.

I am using Aspose now , but it seems that they have nothing to read links between slides.

I read a little more about the PowerPoint 2007/2010 file format and found out that this is just a zip archive. After renaming, you can see all the XML data inside it. Does anyone know which of the many XML files inside it contains information about which slide is linked and which slide?

I need to do this in C # or VB.NET.

+4
source share
2 answers

There is no need to switch to OpenXML, if you do not need it - this can be done using the Object Model. Here's how to do it in VBA, which can be easily ported to C # or VB.NET.

Sub PrintInteralLinks() Dim ap As Presentation Set ap = ActivePresentation Dim hs As Hyperlinks Dim h As Hyperlink Dim sl As Slide Dim linkedToSlide As String Dim slideTitle As Integer For Each sl In ap.Slides Set hs = sl.Hyperlinks For Each h In hs slideTitle = InStrRev(h.SubAddress, ",") If slideTitle > 0 Then linkedToSlide = Mid(h.SubAddress, slideTitle + 1) Debug.Print sl.Name & " links to " & linkedToSlide End If Next Next End Sub 

slideTitle = InStrRev(h.SubAddress, ",") , however, is not a fool. The template for internal links is #,#,Slide Title , so you may have to do it better, as with some RegEx.

+2
source

To accomplish this in C #, here is a good way to find a related slide:

  private int GetSlideIndexFromHyperlink(Hyperlink hyperlink) { var subAddrParts = hyperlink.SubAddress.Split(','); return int.Parse(subAddrParts[1]); } 

Please note that the hyperlink was found within the required ActionSettings settings for the form you care about (in my case it was shape.ActionSettings[PpMouseActivation.ppMouseClick] .

The sub-address for the layout in PowerPoint is formatted as SlideId,SlideIndex,SlideTitle . It is enough to simply get other parts (if desired) using this method using some small settings.

0
source

Source: https://habr.com/ru/post/1313995/


All Articles