views:

66

answers:

1

I`m looking for a way to read a links between slides in single PowerPoint presentation. I need to open a PowerPoint file and retrieve all links slides have to each other.

Right now I`m using Aspose but it appears they do not have anything to read links between slides.

I've read some more about the PowerPoint 2007/2010 file format and found out that it`s just a zip archive. After renaming it you can see all the xml data inside it. Does anybody know which one of the many xml files inside it contains information what slide is linked and to what slide?

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

+2  A: 

There's no need to go to OpenXML here if you don't have to - this can be done with the Object Model. Here's how it is done in VBA, which can easily be 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

The slideTitle = InStrRev(h.SubAddress, ",") isn't fool-proof though. The pattern for internal links is #,#,Slide Title, so you may have to make this better with like some RegEx.

Otaku