Microsoft Office Tutorials and References
In Depth Information
Setting Hyperlinks on Index Entries
' * * * * *¶
Function IsValidEntry(entry As String, _¶
entryLength As Long) As Boolean¶
'Index entry must be at least 4 characters:¶
'entry text, space or tab, page nr, para mark¶
IsValidEntry = False¶
If entryLength > 3 Then¶
'Dont bother if no page number¶
If IsNumeric(Mid(entry, entryLength, 1)) Then¶
IsValidEntry = True¶
End If¶
End If¶
End Function¶
' * * * * *¶
Function ExtractEntryInfo(rngEntry As Word.Range, _¶
entry As String, entryLength As Long) As String¶
'Variable declaration¶
Dim newEntry As IndexEntry¶
Dim pageNumber As String¶
Dim entryCounter As Long¶
Do¶
'Restart the list of pages for this entry¶
ReDim Preserve EntryList(entryCounter)¶
pageNumber = ""¶
'end point for the hyperlink to be inserted¶
newEntry.posEnd = rngEntry.End - _¶
(Len(entry) - entryLength)¶
'get all consecutive numerals (= page number)¶
'at end of entry string¶
Do While IsNumeric(Mid(entry, entryLength, 1))¶
pageNumber = Mid(entry, entryLength, 1) & pageNumber¶
entryLength = entryLength - 1¶
Loop¶
'Add the page number to the list for which¶
'bookmark targets need to be created¶
newEntry.page = pageNumber¶
'start point for the hyperlink to be inserted¶
newEntry.posStart = rngEntry.End - _¶
(Len(entry) - entryLength)¶
'Add this to the entry list that will be processed¶
EntryList(entryCounter) = newEntry¶
entryCounter = entryCounter + 1¶
'skip any spaces between numbers¶
Do While Mid(entry, entryLength, 1) = " "¶
entryLength = entryLength - 1¶
Loop¶
'skip the , separating page numbers¶
Do While Mid(entry, entryLength, 1) = ","¶
entryLength = entryLength - 1¶
Loop¶
Wrd
Search JabSto ::




Custom Search