Discussion:
Getting hyperlink with # tag in Word to go to named anchor in web page
(too old to reply)
Larry
2009-01-07 01:58:34 UTC
Permalink
In Word 97, if I have a plain text url,

http://www.myblog.com/archives/01.html

and press Enter following the url, it turns into an active hyperlink.

But if I have a url that includes the # tag that points to a named anchor in
the target web page, like this,

http://www.myblog.com/archives/01.html#answer

and press Enter, it turns into a hyperlink, but the hyperlink does not go to
the named anchor, it only goes to the top of the web page.

Even if I insert the hyperlink into text in the Word document by using the
Edit Hyperlink dialog box to create a link that includes the # tag, once the
link is created, it only goes to the top of the web page. If I hover the
pointer over the link, the bubble shows the url without the # tag. If I view
the Field Codes (Alt+F9), the codes do display the # tag. Yet the # tag
doesn't work.

So, how do I get a hyperlink in a Word document to go to the named anchor in
a web page?

Thanks.
Larry
Jay Freedman
2009-01-07 03:05:35 UTC
Permalink
Post by Larry
In Word 97, if I have a plain text url,
http://www.myblog.com/archives/01.html
and press Enter following the url, it turns into an active hyperlink.
But if I have a url that includes the # tag that points to a named anchor in
the target web page, like this,
http://www.myblog.com/archives/01.html#answer
and press Enter, it turns into a hyperlink, but the hyperlink does not go to
the named anchor, it only goes to the top of the web page.
Even if I insert the hyperlink into text in the Word document by using the
Edit Hyperlink dialog box to create a link that includes the # tag, once the
link is created, it only goes to the top of the web page. If I hover the
pointer over the link, the bubble shows the url without the # tag. If I view
the Field Codes (Alt+F9), the codes do display the # tag. Yet the # tag
doesn't work.
So, how do I get a hyperlink in a Word document to go to the named anchor in
a web page?
Thanks.
Larry
Word doesn't use the # syntax. Instead, it uses an \l switch (that's a lower
case L after the backslash) followed by the anchor name, as in

{HYPERLINK "http://www.myblog.com/archives/01.html" \l "answer"}


--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so all may benefit.
Larry
2009-01-07 06:20:09 UTC
Permalink
Jay,

I tried that,and looked right, but it didn't work. And when I hover the
pointer over it, the url in the bubble shows the backslash as a forward
slash. Meanwhile, when I display the code, it has two back slashes where
there should be one.

Also, what you're showing to me is the display code and it has quotes around
the url:

{HYPERLINK "http://www.myblog.com/archives/01.html" \l "answer"}

But if I display the code of a hyperlink in a Word document, it doesn't have
quotes in it. (Though sometimes it does, there's no rhyme or reason to it.)
Post by Jay Freedman
Post by Larry
In Word 97, if I have a plain text url,
http://www.myblog.com/archives/01.html
and press Enter following the url, it turns into an active hyperlink.
But if I have a url that includes the # tag that points to a named anchor in
the target web page, like this,
http://www.myblog.com/archives/01.html#answer
and press Enter, it turns into a hyperlink, but the hyperlink does not go to
the named anchor, it only goes to the top of the web page.
Even if I insert the hyperlink into text in the Word document by using the
Edit Hyperlink dialog box to create a link that includes the # tag, once the
link is created, it only goes to the top of the web page. If I hover the
pointer over the link, the bubble shows the url without the # tag. If I view
the Field Codes (Alt+F9), the codes do display the # tag. Yet the # tag
doesn't work.
So, how do I get a hyperlink in a Word document to go to the named anchor in
a web page?
Thanks.
Larry
Word doesn't use the # syntax. Instead, it uses an \l switch (that's a lower
case L after the backslash) followed by the anchor name, as in
{HYPERLINK "http://www.myblog.com/archives/01.html" \l "answer"}
--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so all may benefit.
Jay Freedman
2009-01-07 13:13:55 UTC
Permalink
Part of the problem is that I don't have Word 97 any longer, so I'm working with
what I see in Word 2003. I'm not sure what differences, if any, there are
between the versions.

Try working only with the field code, not with the dialog (which does some
"translation" to try to be helpful, but just gets in the way).

Where you see two backslashes, delete one of them. That's definitely a mistake,
probably introduced by the dialog. Also, make sure there is a space to the left
of the backslash.

The quotes are necessary if there are any spaces (which could happen if the URL
is a file name instead of a web page), and optional for anything else.

If you're still not getting it to work, reply again and paste the exact field
code instead of trying to describe it.
Post by Larry
Jay,
I tried that,and looked right, but it didn't work. And when I hover the
pointer over it, the url in the bubble shows the backslash as a forward
slash. Meanwhile, when I display the code, it has two back slashes where
there should be one.
Also, what you're showing to me is the display code and it has quotes around
{HYPERLINK "http://www.myblog.com/archives/01.html" \l "answer"}
But if I display the code of a hyperlink in a Word document, it doesn't have
quotes in it. (Though sometimes it does, there's no rhyme or reason to it.)
Post by Jay Freedman
Post by Larry
In Word 97, if I have a plain text url,
http://www.myblog.com/archives/01.html
and press Enter following the url, it turns into an active hyperlink.
But if I have a url that includes the # tag that points to a named anchor
in
Post by Jay Freedman
Post by Larry
the target web page, like this,
http://www.myblog.com/archives/01.html#answer
and press Enter, it turns into a hyperlink, but the hyperlink does not go
to
Post by Jay Freedman
Post by Larry
the named anchor, it only goes to the top of the web page.
Even if I insert the hyperlink into text in the Word document by using
the
Post by Jay Freedman
Post by Larry
Edit Hyperlink dialog box to create a link that includes the # tag, once
the
Post by Jay Freedman
Post by Larry
link is created, it only goes to the top of the web page. If I hover the
pointer over the link, the bubble shows the url without the # tag. If I
view
Post by Jay Freedman
Post by Larry
the Field Codes (Alt+F9), the codes do display the # tag. Yet the # tag
doesn't work.
So, how do I get a hyperlink in a Word document to go to the named anchor
in
Post by Jay Freedman
Post by Larry
a web page?
Thanks.
Larry
Word doesn't use the # syntax. Instead, it uses an \l switch (that's a
lower
Post by Jay Freedman
case L after the backslash) followed by the anchor name, as in
{HYPERLINK "http://www.myblog.com/archives/01.html" \l "answer"}
--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup
so all may benefit.
Loading...