Builidng an updatable index or table of contents of hyperlinks

G

Guest

Is it possible to build an updatable index or table of contents of all the
hyperlinks in a document? I have a document that has hyperlinks to other
documents and I would like to generate a table of contents or index of these
links similar to the way the "Index and Tables" works.

BTW, Word 2000 SP3. TIA
 
K

Klaus Linke

Dave said:
Is it possible to build an updatable index or table of contents of all the
hyperlinks in a document? I have a document that has hyperlinks to other
documents and I would like to generate a table of contents or index of
these
links similar to the way the "Index and Tables" works.

BTW, Word 2000 SP3. TIA


Hi Dave,

There's nothing built-in along those lines, but you could create such an
"index" of hyperlinks with a macro.

The macro below will create a list of hyperlinks and their page numbers.
The hyperlinks themselves will act as hyperlinks just as the original links,
and the page numbers will act as hyperlinks back to the hyperlink in the
text.

You may have to clean up double/multiple entries, and could sort the list if
you want to.

You could also use the macro from this post:
http://groups.google.de/group/micro...9a1e3?lnk=st&q=&rnum=1&hl=de#44c753311eb9a1e3
which will create an index for text formatted in some character style (...
change "index style" to "Hyperlink" in the macro code).
This will create a "normal" index, sorted and without multiple entries, but
also without working hyperlinks.

If you need help with running the macro, see
http://word.mvps.org/FAQS/MacrosVBA/CreateAMacro.htm

Regards,
Klaus


Dim myHyperlink As Hyperlink
Dim i As Long
Dim iMax As Long
Dim myBookmark As Bookmark
Dim myRange As Range
iMax = ActiveDocument.Hyperlinks.Count
i = 1
' Delete old bookmarks:
For Each myBookmark In ActiveDocument.Bookmarks
If left(myBookmark.Name, 2) = "Hyperlink" Then
myBookmark.Delete
End If
Next myBookmark
' Insert Bookmarks:
For Each myHyperlink In ActiveDocument.Content.Hyperlinks
With ActiveDocument.Bookmarks
.Add Range:=myHyperlink.Range, Name:="Hyperlink" & Trim(str(i))
.DefaultSorting = wdSortByName
.ShowHidden = True
End With
i = i + 1
Next myHyperlink
' Create "index":
Set myRange = ActiveDocument.Characters.Last.Duplicate
For i = 1 To iMax
myRange.InsertParagraphAfter
myRange.Move Unit:=wdParagraph, Count:=1
myRange.FormattedText = ActiveDocument.Bookmarks("Hyperlink" &
Trim(str(i))).Range
myRange.Move Unit:=wdParagraph, Count:=1
myRange.InsertAfter vbTab
myRange.Move Unit:=wdParagraph, Count:=1
myRange.InsertCrossReference ReferenceType:="Textmarke", ReferenceKind:=
_
wdPageNumber, ReferenceItem:="Hyperlink" & Trim(str(i)),
InsertAsHyperlink:=True, _
IncludePosition:=False, SeparateNumbers:=False, SeparatorString:=" "
myRange.Move Unit:=wdParagraph, Count:=1
Next i
 

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