Need hyperlinks index entries in word 2007

Anonymous
2010-01-30T14:25:46+00:00

Hi All,


I am trying to find a way to get the page numbers in a Word 2007 generated index to contain hyperlinks to the corresponding content in the document. So far I haven't been able to find a way to do this. 

Web searches seem to suggest this could be done with a macro, but that is beyond my skill level. I was wondering if anyone had any other suggestions, or knows of a pre-existing macro I could use to achieve this.


Thanks


Neil


Microsoft 365 and Office | Word | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

48 answers

Sort by: Oldest
  1. Stefan Blom 353.5K Reputation points MVP Volunteer Moderator
    2016-09-10T15:08:58+00:00

    Did you post in the Uservoice forum at http://word.uservoice.com? I don't think that you will get a reply, but Microsoft does consider suggestions which have received votes.

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2016-09-11T06:03:06+00:00

    yes I did...

    After hours of dealing with (not working) suggestions in the web, I made my own solution by VBA. It goes thru the XE-entries, put them in an arry, sort the array and then writes an own index at a bookmark in the document. May be it will become slowly at the end with many Index-entries, I will see.

    If anyone needs: if my work is done, I will post the code here - at the moment I'm in a hurry.

    Thomas

    Was this answer helpful?

    0 comments No comments
  3. Paul Edstein 82,871 Reputation points Volunteer Moderator
    2016-09-11T23:48:34+00:00

    You will undoubtedly find that the Index will not retain the hyperlinks added by your macro. As soon as you do anything that causes the Index to refresh (e.g. a print preview or printing the document), all the hyperlinks will disappear. That's because the Index in Word is a field. The only way around that would be to unlink the Index field, to prevent it updating, before applying the hyperlinks. But then the Index would be incapable of any further updates. Even in a document that's no longer subject to ongoing edits, that could in some cases mean the index entries will reference the wrong page #s as soon as you open the document on another computer - or even on the same computer - with a different active printer. That's because Word uses information from the active printer's driver for layout optimisation.

    Furthermore, adding hyperlinks from an Index to the corresponding entries in the body of the document won't work unless you duplicate the entries for all those case where there is more than one XE field for the same index entry on a given page (a page that can change as soon as you change printer drivers). That's because Word intelligently combines duplicates into a single Index field entry but a hyperlink can only go to one of those entries. This also explains why criticizing Word for not hyperlinking to entries shows a fundamental lack of understanding of what an Index is and how difficult it would be to manage such an arrangement in a document subject to ongoing edits and/or viewing on computers using different printer drivers.

    It's all very well to carry on about how page layout programs can link an Index to a page as some contributors to this thread have done, but page layout programs don't have the ability to optimise a document's layout the way Word does to accommodate changes in printer drivers - and automatically update Tables of Contents, Indexes, Cross-references and the like to take account of that.

    Was this answer helpful?

    0 comments No comments
  4. Anonymous
    2016-09-12T04:31:48+00:00

    Hi Paul

    "my" index is not an index, but a collection of hyperlinks to bookmarks, written by the macro, and they are updatable very well (If there is a new page, my layout has changed or something like that). The link is okay, even if the shown pagenumber not, and the hyperlinks are still there.

    And if I refresh the document, the pagenumber is updated, so the link and the pagenumber are ok both afterwards.

    But surely: "My" index is not updated automatically but must be written newly by starting the macro after creating a new XE-entry.

    the second problem is one: my macro does not like double XE-fields. That is important, i forgot that problem - in the moment I am happy, having an hyperlinked index and have to look that there will be no double index. "my" macro was a development for this one document I am creating just now and which will be a digital pdf at the end (and a printed on paper too).

    Thank you for your justified objection in this case, perhaps I can avoid the problem by numbering the bookmarks for double indexentries when going thru the document, creating the bookmarks. And when writing the index, I should look in VBA whether there is a double index-entry.

    And "My" index is not pretty, that is why I am blaming word for not having a hyperlinked index - the word index is much much much better. But as I am coding very little - I can expect from a company with thousands of experienced programmers, that they will solve a problem, which open since many years. even if it is difficult :-)

    Best regards

    Thomas Keller

    Was this answer helpful?

    0 comments No comments
  5. Paul Edstein 82,871 Reputation points Volunteer Moderator
    2016-09-12T05:27:02+00:00

    Instead of using the .Hyperlinks.Add method, which it seems likely to be the case, you would probably get better results with cross-references to your bookmarks, which you can do using the .Fields.Add method. By including the "\h" switch as part of the Text argument, the cross-reference will both hyperlink to the source and auto-update to reflect pagination changes (which hyperlinks won't do) without imposing the blue underlined font typical of hyperlinks. That will at least give you one less issue to deal with.

    The code for the .Fields.Add method might be implemented along the lines of:

    ActiveDocument.Fields.Add Range:=Rng, Type:=wdFieldPageRef, Text:=StrBkMk & " \h", PreserveFormatting:=False

    where Rng is a Range variable defining the location you want to insert the cross-reference at an StrBkMk is a string variable holding the bookmark's name. These are arguments you would already be using for the Hyperlinks.Add method's Anchor & SubAddress, respectively.

    Was this answer helpful?

    0 comments No comments