Remove Hyperlinks in footnotes?

L

Lofty Becker

I've got a macro - I think originally provided by John McGhie (thanks!)
to remove all hyperlinks from a document:

Dim i As Long
For i = ActiveDocument.Hyperlinks.Count To 1 Step -1
ActiveDocument.Hyperlinks(i).Delete
Next i
End Sub

This works fine for hyperlinks in the text of the document, but doesn't
touch hyperlinks in footnotes.

Is there some way to modify it (or just write a separate macro) that
will clear out the hyperlinks in footnotes?

-Lofty
 
J

JE McGimpsey

Lofty Becker said:
Is there some way to modify it (or just write a separate macro) that
will clear out the hyperlinks in footnotes?

This will clear out all hyperlinks:

Dim rStory As Range
Dim i As Long
For Each rStory In ActiveDocument.StoryRanges
With rStory.Hyperlinks
For i = .Count To 1 Step -1
.Item(i).Delete
Next i
End With
Next rStory

This will clear just the footnote hyperlinks:

Dim i As Long
With ActiveDocument
If .Footnotes.Count >= 1 Then
With .StoryRanges(wdFootnotesStory).Hyperlinks
For i = .Count To 1 Step -1
.Item(i).Delete
Next i
End With
End If
End With
 
L

Lofty Becker

JE McGimpsey said:
This will clear out all hyperlinks:

Dim rStory As Range
Dim i As Long
For Each rStory In ActiveDocument.StoryRanges
With rStory.Hyperlinks
For i = .Count To 1 Step -1
.Item(i).Delete
Next i
End With
Next rStory

This will clear just the footnote hyperlinks:

Dim i As Long
With ActiveDocument
If .Footnotes.Count >= 1 Then
With .StoryRanges(wdFootnotesStory).Hyperlinks
For i = .Count To 1 Step -1
.Item(i).Delete
Next i
End With
End If
End With

thank you, thank you! Both versions helpful.

-Lofty
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top