Supercharge your PowerPoint productivity with

Supercharge your PPT Productivity with PPTools - Click here to learn more.

Tell me about PPTools

Bad hyperlinks in PDFs from Acrobat


PPTools
Shape Styles brings the power of styles to PowerPoint. Apply complex formatting with a single click
Merge Excel, CSV or tab-delimited data into PowerPoint presentations to create certificates, awards presentations, personalized presentations and more
FixLinks prevents broken links when you distribute PowerPoint presentations
Optimizer saves disk space and bandwidth, shrinks your PowerPoint presentations to the right size for email, screenshow or printing
PPT2HTML gives you full control of PowerPoint HTML output, helps meet Section 508 accessibility requirements
Prep4PDF preserves interactivity in PowerPoint presentations when you convert to PDF
Image Export converts PowerPoint slides to JPG, PNG, GIF, WMF and more

Problem

When you create hyperlinks and then rearrange or delete slides, then make a PDF using Adobe Acrobat, the links that Acrobat creates in the PDF may point to the wrong slides.

Solution

If you've re-ordered your presentation or added/deleted slides, make a copy of the presentation then run this macro on the copy of your presentation before using Acrobat to create a PDF.

But first, a word from our sponsor ... the PPTools Prep4PDF add-in takes care of this problem automatically. Try the free demo and see for yourself.

Sub FixForAcrobat()

    On Error GoTo ErrorHandler

    Dim oSl As Slide
    Dim oHl As Hyperlink
    Dim sSlideID As String
    Dim sSlideIndex As String
    Dim sSlideTitle As String
    Dim sTemp As String

    For Each oSl In ActivePresentation.Slides
        For Each oHl In oSl.Hyperlinks
            With oHl
                If .Address = "" Then
                    ' it's a link to another slide in this pres
                    ' verify that the slide number and ID of the link target match

                    ' parse out slide number and slideID
                    sSlideID = Mid$(.SubAddress, 1, InStr(.SubAddress, ",") - 1)
                    sTemp = Mid$(.SubAddress, InStr(.SubAddress, sSlideID) + Len(sSlideID) + 1)
                    sSlideIndex = Mid$(sTemp, 1, InStr(sTemp, ",") - 1)
                    sSlideTitle = Mid$(sTemp, InStr(sTemp, ",") + 1)

                    ' If the linked slide isn't present, we get an error so test first:
                    On Error Resume Next
                    If ActivePresentation.Slides.FindBySlideID(CLng(sSlideID)) Is Nothing Then
                        MsgBox "Link to missing slide on slide: " & CStr(oSl.SlideIndex) _
                            & vbCrLf _
                            & "Link points to: " & .SubAddress
                        ' stop processing this hyperlink
                        Exit For
                    End If
                    On Error GoTo ErrorHandler

                    If ActivePresentation.Slides.FindBySlideID(CLng(sSlideID)).SlideIndex <> sSlideIndex Then
                        ' the link will confuse Acrobat so fix it
                        Debug.Print "Originally:" & vbTab & .SubAddress
                            On Error Resume Next
                            sTemp = sSlideID & "," _
                            & ActivePresentation.Slides.FindBySlideID(CLng(sSlideID)).SlideIndex & "," _
                            & sSlideTitle
                         ' If target slide not present, don't reset link
                         If Err.Number = 0 Then
                             .SubAddress = sTemp
                        End If
                        Debug.Print "Now:" & vbTab & sTemp
                    End If

                End If
            End With
        Next
    Next

NormalExit:
    Exit Sub

ErrorHandler:
    MsgBox "Error:" & vbCrLf & Err.Number & vbTab & Err.Description
    Resume NormalExit

End Sub

See How do I use VBA code in PowerPoint? to learn how to use this example code.

Background

PowerPoint stores several "pointers" in its internal hyperlinks. For each slide linked to, it stores the following information for the slide:

  • The SlideID, a unique number assigned by PowerPoint, which never changes even when you reorder your presentation
  • The SlideIndex, the current order of the slide within the presentation (ie, if SlideIndex = 42, then this is the 42nd slide in the presentation). This changes when you reorder the slides, of course.
  • The title text of the slide

The second and third bits don't change as the result of editing the presentation, so the SlideID is the only reliable pointer to use. Acrobat evidently uses the SlideIndex, with the result that if you have a link from Slide 2 to Slide 10 and then delete Slide 4, the link will point to the slide that's NOW at Index 10, but was originally slide 11.

PowerPoint resolves the problem by using the SlideID when it follows the link; Acrobat produces a bad link in the PDF.

The macro above checks each hyperlink to make sure that the link's SlideIndex and the SlideID both point to the same slide. If they don't, it finds the Index of the slide at the SlideID and resets the link to it.


Page copy protected against web site content infringement by Copyscape Contents © 1995-2008 Stephen Rindsberg, Rindsberg Photography, Inc. and members of the MS PowerPoint MVP team. You may link to this page but any form of unauthorized reproduction of this page's contents is expressly forbidden.

Español    Deutsch    Français    Português    Italiano    Nederlands    Greek    Japanese    Korean    Chinese



Supercharge your PPT Productivity with PPTools


content authoring & site maintenance by
Friday, the automatic faq maker (logo)
Friday - The Automatic FAQ Maker

Bad hyperlinks in PDFs from Acrobat
http://www.pptfaq.com/FAQ00744.htm
Last update 12 September, 2006