Is it possible to create a URL that has an anchor to a particular location within a Microsoft Word 2007 document? Normally, I create an anchor URL by adding #anchorName to the URL. Can I do this with a URL that points to a word document? If so, how do I control the anchor names inside word? I wish to link to a particular subsection of the document.



1 answer

danwellman 5600
This was chosen as the best answer

You can do this, but it will only work in IE unfortunately. There are several steps to doing it:

1) In Word you need to highlight the text that will be the clickable link then click the Insert Hyperlink button. In the dialog that appears, choose the Place in this document button at the left, which will give you a document map showing all of the headings in the document (you need to have headings to link to). Then you just select whichever heading you would like to link to. This will then create the link.

2) In your web page add the a element in the usual way. The href should be the name of the document, and the document fragment link, so something like this:

<a href="myWordDocument.doc#_The_Heading_To_Link_To">Link to Word Doc</a>

The document fragment is almost identical to a normal web page document fragment, except that with Word, the fragment needs to begin with an underscore, and any spaces in the heading text should be replaced with underscores too (remember we are linking to a heading within the Word doc)

When you click the link in IE (I tested in IE8), the word doc opens inside IE and navigates automatically to the specified heading.

Other browsers cannot natively open Word docs (although there may be plugins to allow it) so the Word doc will open in Word instead of in the browser, and the Word doc will open at the beginning of the Document, not the specified heading.

This could still be a valuable tool if it is used in, e.g. a company intranet where the whole company uses IE and you don't need to worry about other browsers.

Answered over 7 years ago by danwellman