Microsoft Office Tutorials and References
In Depth Information
Setting Hyperlinks on Index Entries
Tip: Click on any page number in the hyperlinked index to jump to the first instance of the index
entry on the given page.
View the Appendix to learn how to store this procedure
in a Standard module.
Option explicit¶
' * * * * *¶
Private EntryList() As IndexEntry¶
Private nrEntries As Long¶
Private Const bookmarkIdentifier = "_txt"¶
Private Type IndexEntry¶
page As String¶
posStart As Long¶
posEnd As Long¶
End Type¶
' * * * * *¶
Sub HyperlinkIndex()¶
'Variable declaration¶
Dim doc As Word.Document¶
Dim rngIndex As Word.Range¶
Dim para As Word.Paragraph¶
Dim rngEntry As Word.Range¶
Dim entry As String¶
Dim searchTerm As String¶
Dim entryLength As Long¶
Dim bookmarkName As String¶
Dim linkCounter As Long¶
'index term is used as basis for bookmark¶
'hyperlink target¶
'increment number for each bookmark target¶
'in case of more than one entry with same name¶
Application.ScreenUpdating = False¶
nrEntries = 0¶
Set doc = ActiveDocument¶
Set rngIndex = GetIndexRange(doc)¶
'Get the range with the index¶
If rngIndex Is Nothing Then¶
MsgBox "No index could be found in the active document.", _¶
vbOKOnly + vbInformation, "Hyperlink index"¶
Exit Sub¶
End If¶
Search JabSto ::

Custom Search