h2whoa
11-29-2016, 10:32 AM
I have a massive slide deck (978 slides). Nearly every slide has at least 1 hyperlink on it. I have a code that extracts every single hyperlink into a text file, reporting:
Slide number
Whether the link is embedded in text or a shape
What shape it occurs in
What the url is
So the current report I get reads as: (for example)
Slide: 3
HYPERLINK IN SHAPE
Shape: Freeform 11
Address: example1URL
Slide: 4
HYPERLINK IN TEXT
Shape: Text Box 2
Address: example2URL
I now need to show what the actual text is that has been hyperlinked (or the text in the shape that has been hyperlinked) in between points 3 and 4. I'm sure that's a relatively simple fix, but I just can't get it to work. The original code that produces the 4 point report is below. If someone can help me with what I need to add to get the text, I'd be eternally grateful!
Sub ExtractHyperlinks()
Dim oS1 As Slide
Dim oH1 As Hyperlink
Dim sReport As String
Dim iFileNum As Integer
Dim sFileName As String
For Each oS1 In ActivePresentation.Slides
For Each oH1 In oS1.Hyperlinks
If oHl.Type = msoHyperlinkShape Then
If oHl.Address <> "" Then
sReport = sReport & "HYPERLINK IN SHAPE" _
& vbCrLf _
& "Slide: " & vbTab & oS1.SlideIndex _
& vbCrLf _
& "Shape: " & oH1.Parent.Parent.Name _
& vbCrLf _
& "Address:" & vbTab & oHl.Address & vbCrLf & vbNewLine
Else
sReport = sReport & ""
End If
Else
If oH1.Address <> "" Then
sReport = sReport & "HYPERLINK IN TEXT" _
& vbCrLf _
& "Slide: " & vbTab & oS1.SlideIndex _
& vbCrLf _
& "Shape: " & oH1.Parent.Parent.Parent.Parent.Name _
& vbCrLf _
& "Address:" & vbTab & oHl.Address & vbCrLf & vbNewLine
Else
sReport = sReport & ""
End If
End If
Next
Next
iFileNum = FreeFile()
sFileName = Environ("USERPROFILE") & "\Desktop\Report.txt"
Open sFileName For Output As iFileNum
Print #iFileNum, sReport
Close #iFileNum
Call Shell("NOTEPAD.EXE " & sFileName, vbNormalFocus)
End Sub
Slide number
Whether the link is embedded in text or a shape
What shape it occurs in
What the url is
So the current report I get reads as: (for example)
Slide: 3
HYPERLINK IN SHAPE
Shape: Freeform 11
Address: example1URL
Slide: 4
HYPERLINK IN TEXT
Shape: Text Box 2
Address: example2URL
I now need to show what the actual text is that has been hyperlinked (or the text in the shape that has been hyperlinked) in between points 3 and 4. I'm sure that's a relatively simple fix, but I just can't get it to work. The original code that produces the 4 point report is below. If someone can help me with what I need to add to get the text, I'd be eternally grateful!
Sub ExtractHyperlinks()
Dim oS1 As Slide
Dim oH1 As Hyperlink
Dim sReport As String
Dim iFileNum As Integer
Dim sFileName As String
For Each oS1 In ActivePresentation.Slides
For Each oH1 In oS1.Hyperlinks
If oHl.Type = msoHyperlinkShape Then
If oHl.Address <> "" Then
sReport = sReport & "HYPERLINK IN SHAPE" _
& vbCrLf _
& "Slide: " & vbTab & oS1.SlideIndex _
& vbCrLf _
& "Shape: " & oH1.Parent.Parent.Name _
& vbCrLf _
& "Address:" & vbTab & oHl.Address & vbCrLf & vbNewLine
Else
sReport = sReport & ""
End If
Else
If oH1.Address <> "" Then
sReport = sReport & "HYPERLINK IN TEXT" _
& vbCrLf _
& "Slide: " & vbTab & oS1.SlideIndex _
& vbCrLf _
& "Shape: " & oH1.Parent.Parent.Parent.Parent.Name _
& vbCrLf _
& "Address:" & vbTab & oHl.Address & vbCrLf & vbNewLine
Else
sReport = sReport & ""
End If
End If
Next
Next
iFileNum = FreeFile()
sFileName = Environ("USERPROFILE") & "\Desktop\Report.txt"
Open sFileName For Output As iFileNum
Print #iFileNum, sReport
Close #iFileNum
Call Shell("NOTEPAD.EXE " & sFileName, vbNormalFocus)
End Sub