Supercharge your PowerPoint productivity with
|
PPTools |
ProblemWhen 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. SolutionIf 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. BackgroundPowerPoint stores several "pointers" in its internal hyperlinks. For each slide linked to, it stores the following information for 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. Español Deutsch Français Português Italiano Nederlands Greek Japanese Korean Chinese |
Supercharge your PPT Productivity with PPTools
|
content authoring & site maintenance by |
Bad hyperlinks in PDFs from Acrobat
http://www.pptfaq.com/FAQ00744.htm
Last update 12 September, 2006