Microsoft Office Tutorials and References
In Depth Information
Setting Hyperlinks on Index Entries
'Remove any bookmarks from previous runs¶
DeleteAllIndexBookmarks doc, bookmarkIdentifier¶
'turn it into plain text¶
rngIndex.Fields.Unlink¶
For Each para In rngIndex.Paragraphs¶
'Process each paragraph in the index range¶
Set rngEntry = para.Range¶
'Pick up only the field result, not the code¶
rngEntry.TextRetrievalMode.IncludeFieldCodes = False¶
entry = rngEntry.Text¶
entryLength = Len(entry) - 1 'cut off para mark¶
If IsValidEntry(entry, entryLength) Then¶
searchTerm = ExtractEntryInfo(rngEntry, _¶
entry, entryLength)¶
'Process each page number for the index entry¶
bookmarkName = DeriveName(doc, searchTerm)¶
For linkCounter = 0 To UBound(EntryList)¶
CreateHyperlinkAndTarget doc, searchTerm, _¶
bookmarkName, linkCounter, rngIndex¶
Next¶
End If¶
ReDim EntryList(0)¶
Next para¶
End Sub¶
' * * * * *¶
'Find the Index, if it exists by looping through¶
'the fields and testing the type¶
'Returns "Nothing" if Index field is not present¶
Function GetIndexRange(doc As Word.Document) As Word.Range¶
'Variable declaration¶
Dim fld As Word.Field¶
For Each fld In doc.Fields¶
If fld.Type = wdFieldIndex Then¶
Set GetIndexRange = fld.Result¶
Exit For¶
End If¶
Next fld¶
End Function¶
' * * * * *¶
Sub DeleteAllIndexBookmarks(doc As Word.Document, _¶
identifier As String)¶
'Variable declaration¶
Dim bkm As Word.Bookmark¶
For Each bkm In doc.Bookmarks¶
If Left(bkm.Name, Len(identifier)) = _¶
identifier Then bkm.Delete¶
Next¶
End Sub¶
Wrd
Search JabSto ::




Custom Search