This Microsoft Word 2003 macro is very useful when run against web pages containing a lot of links, after first having cut and pasted them into Microsoft Word 2003. It will mark a hyperlink found with a footnote number and put the URL as a footnote.
Example:

'****************************************************************************
' CreateFootnotesFromHyperlinks - Copyright (c) 2004 Per Soderlind
'
' The macro creates footnotes from HTML hyperlinks
'
' NOTE: Very useful when run against web pages containing a lot of
' links -- after having first cut and pasted the web page into word.
' The macro is only tested in Microsoft Word 2003
'
' This work is licensed under a Creative Commons License:
' http://creativecommons.org/licenses/by-nc-sa/2.0/
'
'****************************************************************************
Option Base 1
Public Sub CreateFootnotesFromHyperlinks()
Dim MyRange As Range, i As Long, linkFound As Boolean
linkFound = False
Btn = MsgBox("Create footnotes from hyperlinks?" + Chr(13) + Chr(13) _
+ "NOTE: Hyperlinks will be removed from the document", vbYesNo, "Create Footnotes from Hyperlinks")
If Btn = vbNo Then Exit Sub
For i = ActiveDocument.Hyperlinks.Count To 1 Step -1
If Len(Trim(ActiveDocument.Hyperlinks(i).Address)) > 0 Then
linkFound = True
Set MyRange = ActiveDocument.Hyperlinks(i).Range
ActiveDocument.Footnotes.Add Range:=MyRange, Reference:="",Text:=ActiveDocument.Hyperlinks(i).Address
ActiveDocument.Hyperlinks(i).Delete
MyRange.Style = wdStyleHyperlink
End If
Next i
If Not linkFound Then
Btn = MsgBox("NO hyperlinks found", vbExclamation, "Extract Hyperlinks")
Exit Sub
End If
End Sub

Post a Comment