From: Greg Maxey on
Jonathan,

Thanks. That is a lesson re-learned ;-)

"Jonathan West" <jwest(a)mvps.org> wrote in message
news:eOjlrVlgKHA.5528(a)TK2MSFTNGP05.phx.gbl...
>
> "Pesach Shelnitz" <pesach18(AT)hotmail.com> wrote in message
> news:507CC8E1-D818-4EE6-9DFC-528029364DAB(a)microsoft.com...
>> Hi Raph,
>>
>> In general, to delete all the objects from a collection in VBA, you need
>> a
>> For loop that iterates through the collection in descending order. The
>> first
>> of the following macros converts all the hyperlinks in the active
>> document to
>> ordinary text, and the second macro completely erases all the hyperlinks.
>>
>> Sub ConvertHyperlinksToText()
>> Dim i As Long
>>
>> With ActiveDocument
>> For i = .Hyperlinks.Count To 1 Step -1
>> .Hyperlinks(i).Delete
>> Next
>> End With
>> End Sub
>>
>> Sub DeleteHyperlinks()
>> Dim i As Long
>>
>> With ActiveDocument
>> For i = .Hyperlinks.Count To 1 Step -1
>> .Hyperlinks(i).Range.Delete
>> Next
>> End With
>> End Sub
>>
>
>
> In fact, if you have a large number of hyperlinks to delete, the following
> versions will be somewhat faster. You probably won't notice much
> difference unless there are hundreds or even thousands of hyperlinks in a
> document.
>
> Sub ConvertHyperlinksToText()
> Dim i As Long
>
> With ActiveDocument
> For i = 1 to .Hyperlinks.Count
> .Hyperlinks(1).Delete
> Next
> End With
> End Sub
>
> Sub DeleteHyperlinks()
> Dim i As Long
>
> With ActiveDocument
> For i = 1 to .Hyperlinks.Count
> .Hyperlinks(1).Range.Delete
> Next
> End With
> End Sub
>
>
> The code looks a bit odd - repeatedly deleting the first link - but it
> works because you are repeatedly deleting the first hyperlink in the
> document from among those that remain after the last deletion.
>
> The reason it is faster is that accessing the first member of a collection
> is almost always faster than accessing the last, and the speed advantage
> increases with the number of items in the collection.
>
>
> --
> Regards
> Jonathan West