Hi Jack,
I'm looking for a VBA macro that will hyperlink the page numbers (or
entries) in a generated index back to the XE fields from which they're
generated. I'd be grateful for any help you can give.
I did something like this, many years ago. Basically, it involves
1. Storing the Range of the Index in a Range variable
2. Unlinking the Index field (to make it static text)
3. "Walking" each paragraph (=Index entry)
4. Store the text part of the Index entry in a string variable. Exactly
how to do this (make sure you get only the text) depends on what kind of
index you have. Generally, I found it expedient to start at the end of
the paragraph with a Range, and move the start point of the Range towards
the start of the paragraph as long as it returns a numeric value / until
it hits a separator character. Store this in an array for later. Continue
until after any separator characters text comes instead of a number -
what's left is the text entry.
5. Take each (page) number, get a Range object for it, then use Find to
pick up the (first) entry on that page. Place a bookmark at that entry,
and create a hyperlink field around the number in the index entry for
that bookmark.
Exact details vary according to the document and the type of index, but
that's the basic approach.
A variation on the approach is to use the WindowBeforeDoubleClick event.
In this case you can get away with not unlinking the index, but things
will be slower as the entire sequence of calculations has to be performed
each time.
Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org
This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail
![Smile :) :)](data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)