Group: microsoft.public.word.vba.general
From: IdontWantSpam@nospam.net (Edward Thrashcort)
Date: Tuesday, October 23, 2007 3:34 PM
Subject: Re: Removing ALL hyperlinks

Interesting! I'll remember that trick.

Eddie

> *From:* "Jonathan West"
> *Date:* Sat, 4 Aug 2007 13:57:52 +0100
>
>
> "Edward Thrashcort" wrote in message
> news:memo.20070803190932.5928G@eonsol.compulink.co.uk...
> >> Dim n As Long
> >> For n = 1 to ActiveDocument.Range.Hyperlinks.Count
> >> Activedocument.Range.Hyperlinks(1).Delete
> >> Next n
> >
> > Should that be
> >
> > For n = ActiveDocument.Range.Hyperlinks.Count Step -1
> > Activedocument.Range.Hyperlinks(n).Delete
> > Next n
> >
>
> Try it the various different ways. They both work, but my way is
> marginally the faster. The reason is that while the collection of
> hyperlinks is presented as a collection, its underlying implementation is
> not a linked list, and it therefore takes more time to get at the last
> hyperlink in the set than the first.
>
> Each time you remove the first hyperlink, the next one becomes the first,
> and therefore the easiest to get at. You repeat that process as many
> times as there were hyperlinks at the start.
>
> Believe me, I have studied and tested this quite extensively. The code
> looks a bit counterintuitive, but once you understand the underlying
> issues, it does become clear.
>
> --
> Regards
> Jonathan West - Word MVP
> www.intelligentdocuments.co.uk
> Please reply to the newsgroup
>
>
>

Safety Articles | News in English | 20lbs in 30 days | Bluegrass | Usenet Newsfeeds