Skip to content

Create footnotes from hyperlinks

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:

sample footnote from link

'****************************************************************************
' 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
Creative Commons License
This work is licensed under a Creative Commons License.
For commercial use, please contact me.

This website uses IntenseDebate comments, but they are not currently loaded because either your browser doesn't support JavaScript, or they didn't load fast enough.

Post a Comment

Your email is never published nor shared. Required fields are marked *
*
*

@soderlind on Twitter:

Powered by Twitter Tools

Rodney's 404 Handler Plugin plugged in.