Table of Contents anomaly in "Hyperlink Base"

User avatar
ChrisGreaves
PlutoniumLounger
Posts: 15498
Joined: 24 Jan 2010, 23:23
Location: brings.slot.perky

Table of Contents anomaly in "Hyperlink Base"

Post by ChrisGreaves »

(Word2003, but possibly other MS applications and other versions)
Carrying on with my work from "Differentiate between "character" and "hyperlinked character" in a string in MSWord(2003)" I had reason to make the hyperlink paths absolute:-
Untitled1.png
.
To learn why I used "x" please see this thread.
To my dismay, the link from my TOC is rendered useless:-
Untitled2.png
When I "Click" (or Ctrl-Click, I tested the option) in my TOC I no longer get transferred to the corresponding Heading-style paragraph.

I suspect that this is an oversight from the early days of Word97, or even earlier. An Annoyance.

(signed) "downhearted" of Bonavista. :sad:
You do not have the required permissions to view the files attached to this post.
An expensive day out: Wallet and Grimace

User avatar
HansV
Administrator
Posts: 78236
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Table of Contents anomaly in "Hyperlink Base"

Post by HansV »

I can't reproduce the problem in Word 2019.
Best wishes,
Hans

User avatar
kdock
5StarLounger
Posts: 720
Joined: 21 Aug 2011, 21:01
Location: The beautiful hills of Western North Carolina

Re: Table of Contents anomaly in "Hyperlink Base"

Post by kdock »

I'm afraid the links you supplied have made me light-headed. Are you ultimately struggling with TOC hyperlinks within a single document?

I've never used the Hyperlink Base, so I may never know what I've been missing. I also haven't used a Turing Machine or hyperlinks linked to other documents. Is your TOC compiled from different documents?

I've always used styles when creating Headings (with or without a number attached to it), and I'm fairly certain you can turn your TOC into links back to the same document with styles alone, even in Word 2003. But I'm not at all certain that's what you're trying to do.

I won't inflict more info on you if what you want goes beyond the scope of a single document.

Kim :laugh:
"Hmm. What does this button do?" Said everyone before being ejected from a car, blown up, or deleting all the data from the mainframe.

User avatar
ChrisGreaves
PlutoniumLounger
Posts: 15498
Joined: 24 Jan 2010, 23:23
Location: brings.slot.perky

Re: Table of Contents anomaly in "Hyperlink Base"

Post by ChrisGreaves »

kdock wrote:
07 Sep 2021, 21:20
Are you ultimately struggling with TOC hyperlinks within a single document?
Hello Kim.
No. And Yes.
I am not struggling; more finding this apparent bug an annoyance, an item of curiousity value more than anything else. That said I have created a document from scratch this morning for you (or others) to play with should you feel inclined. That, plus anyone who wants to check this out on another version can do so using a common source document (attached TOC-Hyperlinks.doc)
I've never used the Hyperlink Base, so I may never know what I've been missing. I also haven't used a Turing Machine or hyperlinks linked to other documents. Is your TOC compiled from different documents?
Don't sweat the Turing Machines; that's just the height of my passion right now(grin). My TOCs are always composed in place using only Heading paragraphs from the host document. In Word2003 Insert, Reference, Index and tables, Table of Contents, <Enter>. The bit about hyperlinks and TOC comes about only because I am in the habit of clicking on a TOC entry and being taken directly to that Heading paragraph in the body of the document. For me it is a "GoTo" mechanism. This mechanism now fails me the moment I switch a document (holding a TOC) into "Absolute Hyperlink" mode, which I find necessary for my purposes with Turing Machines. Anyone else using some versions of Word (possibly Excel, PowerPoint etc) where they need absolute hyperlinks might find the same problem.
Apart from TOC contents, I need the absolute hyperlinks in the body of my document; there it is that I want to be able to follow a specific hyperlink to any place on my hard drive.

So my thread is more a heads-up in case others wonder why a TOC does not honour the GoTo a heading paragraph. You might be puzzled if i emailed to you a document in which your version of Word suddenly appeared not to honour the GoTo technique in our TOC; "HYperlink Base might be the reason why".
Note too that as far as I know, Originators of documents (that's Me!) need establish this Hyperlink Base only during construction of the document. In theory I can disable the mechanism before exporting the document to the world. (Second attachment: TOC-Hyperlinks_DISABLED.doc)
I've always used styles when creating Headings (with or without a number attached to it), and I'm fairly certain you can turn your TOC into links back to the same document with styles alone, even in Word 2003. But I'm not at all certain that's what you're trying to do.
I too use styles, exclusively Heading-1 through Heading-4, to generate a TOC.

The attached document TOC-Hyperlinks.doc: I have been a tad concerned about the instances on the web where the lower-case letter "x" is suggested as the contents of the hyperlink base. Hans makes comments amongst which :-

Code: Select all

If the Hyperlink Base property contains a valid path, hyperlinks will be relative to that path.
If the Hyperlink Base property contains a string that doesn't correspond to a valid path
And it seems to me that one might have a valid path "x" somewhere.
So in my attached example I have used the question-mark symbol "?" on the grounds that it renders the box non-empty, and yet cannot possibly be a valid path. The asterisk symbol "*" would do as well.

Cheers
Chris
You do not have the required permissions to view the files attached to this post.
An expensive day out: Wallet and Grimace

User avatar
kdock
5StarLounger
Posts: 720
Joined: 21 Aug 2011, 21:01
Location: The beautiful hills of Western North Carolina

Re: Table of Contents anomaly in "Hyperlink Base"

Post by kdock »

Hey Chris,

So what you're saying is that in Word 2003, when you add the "?" to the Hyperlink base field you can no longer make use of the hyperlink TOC feature, right? Hmm.

I downloaded your documents to test them in my current version of Word (2016/O365). When I press Ctrl-Click I am immediately whisked to the appropriate Heading in either document, so the "?" made no difference to TOC hyperlink.

I took a look at one of those places that said to put an "x" in the Hyperlink base field. Out of curiosity, with your first document open, I took a look at Options>Advanced>Web Options>Browsers. It's in a different place than in 2003, but it's there.

browser_issue.jpg

In the dropdown, the highest browser available in this list is IE6 "or later". Since the hyperlinking stuff seems to be tied to browsing stuff, does it do anything if you uncheck "Disable features not supported by these browsers"? There's always been an unholy alliance between Office and IE (which officially ended less than one month ago!) to accomplish some tasks. Just a thought.

I guess this functionality also might have been overhauled in the transition to the XML format. Of course, that and fifty cents will get you... fifty cents. Can one still get a cup of coffee for fifty cents? Anyway, beyond these observations I'm afraid I can't help.

Kim :scratch:
You do not have the required permissions to view the files attached to this post.
"Hmm. What does this button do?" Said everyone before being ejected from a car, blown up, or deleting all the data from the mainframe.

User avatar
ChrisGreaves
PlutoniumLounger
Posts: 15498
Joined: 24 Jan 2010, 23:23
Location: brings.slot.perky

Re: Table of Contents anomaly in "Hyperlink Base"

Post by ChrisGreaves »

kdock wrote:
12 Sep 2021, 23:04
So what you're saying is that in Word 2003, when you add the "?" to the Hyperlink base field you can no longer make use of the hyperlink TOC feature, right?
Hi Kim.
All members of Eileen's Lounge, including me, would be grateful if you would quit whatever it is you are doing and start work full-time as my thread/post writer. :grin: You have hit the proverbial nail on the head with amazing succintiousness..

Some days after my initial post I have upped the probability that this behaviour is a quirk of my Win10P/Word2003 combination; indeed, it might be one of the rare bugs that MS fixed.
My post was intended as a notice to anyone else who had the same problem.
... in my current version of Word (2016/O365). When I press Ctrl-Click I am immediately whisked to the appropriate Heading ...
Thank you for this test. Noone is likely to test in Word2003 (although I think I have a user in Maryland who might oblige) and I don't feel like reinstalling Win10/Office2003 to see if a clean install fixes this trivial problem.
I took a look at one of those places that said to put an "x" in the Hyperlink base field. Out of curiosity, with your first document open, I took a look at Options>Advanced>Web Options>Browsers. It's in a different place than in 2003, but it's there.
In the dropdown, the highest browser available in this list is IE6 "or later". Since the hyperlinking stuff seems to be tied to browsing stuff, does it do anything if you uncheck "Disable features not supported by these browsers"?
I had not known of these features (Advanced, Web).
Untitled.png
I unchecked the box, opened my file "TOC-Hyperlinks.doc", and inspected the box: Checked ON, so this looks like a document option rather than a MSWord-wide option ("The Word-wide-web option?" :flee:). Checked the box OFF for "TOC-Hyperlinks.doc" and tried to jump to a heading with "Click":-
Untitled2.png
Can one still get a cup of coffee for fifty cents? Anyway, beyond these observations I'm afraid I can't help.
At 60 Canon Bayley, any time of day or night.
You have helped confirm my belief that this problem is limited to Word2003, and you have led me to Advanced, Web, so thank you for this!
Cheers
Chris
You do not have the required permissions to view the files attached to this post.
Last edited by ChrisGreaves on 19 Apr 2022, 22:10, edited 1 time in total.
An expensive day out: Wallet and Grimace

User avatar
ChrisGreaves
PlutoniumLounger
Posts: 15498
Joined: 24 Jan 2010, 23:23
Location: brings.slot.perky

Re: Table of Contents anomaly in "Hyperlink Base"

Post by ChrisGreaves »

ChrisGreaves wrote:
07 Sep 2021, 13:50
(Word2003, but possibly other MS applications and other versions)
I have cobbled together some code to render all relative hyperlinks in a document to an absolute form. This works at least in my little folder tree for the current project. I have not tested it across the entire data drive.
I am of two minds as to whether have the macro set the Hyperlink Base on while it is at it; there are arguments for and against.
The heavy lifting is done by two functions from StackOverflow.
cheers
Chris
You do not have the required permissions to view the files attached to this post.
An expensive day out: Wallet and Grimace

User avatar
ChrisGreaves
PlutoniumLounger
Posts: 15498
Joined: 24 Jan 2010, 23:23
Location: brings.slot.perky

Re: Table of Contents anomaly in "Hyperlink Base"

Post by ChrisGreaves »

HansV wrote:
07 Sep 2021, 14:26
I can't reproduce the problem in Word 2019.
I have stumbled upon a readable thread from 2005, Cindy Mesister.
I have yet to dissect and test it in detail but these caught my eye as a bit of a heads-up:-

""For these last, relative paths are supported (but only in relation to Word's current "active" folder, not the document)"
and
"Just be aware that Word may come behind you and change your edited HYPERLINK field codes"

Cheers
Chris
An expensive day out: Wallet and Grimace

User avatar
ChrisGreaves
PlutoniumLounger
Posts: 15498
Joined: 24 Jan 2010, 23:23
Location: brings.slot.perky

Re: Table of Contents anomaly in "Hyperlink Base"

Post by ChrisGreaves »

ChrisGreaves wrote:
07 Sep 2021, 13:50
(Word2003, but possibly other MS applications and other versions)
I am tempted to start a new thread "flogging a dead horse".

This thread in www.excelforum.com/ suggested the use of the Document.properties to set a Hyperlink base with VBA.
I used (Word2003)

Code: Select all

ThisDocument.BuiltInDocumentProperties("Hyperlink Base") = ThisDocument.BuiltInDocumentProperties("Hyperlink Base") = ThisDocument.Path
and a couple of test runs - including saving, closing, and reopening the Word2003 document - show that the setting isn't being made.
Untitled.png
I notice that in Word2003 the property 'Hyperlink base" is not listed, so, well, OK, I guess.

Recording a macro leaves me with a null macro; no clues there.

Can anyone suggest a VBA method for setting hyperlink base in VBA?

I am at the stage where the specific application requires relative hyperlinks, so setting File, Properties, Hyperlink base to "ThisDocument.Path" makes sense to me.
If you were a user making use of my application, this would be a recommended option; my application would assure relative hyperlinks by setting Hyperlink base.
I always have the option of engineering my own relative address regardless of the setting of Hyperlink Base.

Thanks
Chris
You do not have the required permissions to view the files attached to this post.
An expensive day out: Wallet and Grimace

User avatar
HansV
Administrator
Posts: 78236
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Table of Contents anomaly in "Hyperlink Base"

Post by HansV »

In Word 2019, the line

Code: Select all

ThisDocument.BuiltInDocumentProperties("Hyperlink Base") = ...
does set the hyperlink base, and it is saved with the document.

It won't work in Excel of course, you have to use ThisWorkbook there instead of ThisDocument.

Keep in mind that ThisDocument and ThisWorkbook refer to the document/workbook that contains the code, not necessarily to the active document/workbook.
Best wishes,
Hans

User avatar
Jay Freedman
Microsoft MVP
Posts: 1312
Joined: 24 May 2013, 15:33
Location: Warminster, PA

Re: Table of Contents anomaly in "Hyperlink Base"

Post by Jay Freedman »

In Word 2003 and later (I tested in 2003 and the latest Microsoft 365), this works too:

Code: Select all

ActiveDocument.BuiltInDocumentProperties(wdPropertyHyperlinkBase) = . . .
The constant wdPropertyHyperlinkBase has the decimal value 29. This is discoverable by opening the Object Browser (F2) and using its search box to look for "hyperlinkbase".

User avatar
ChrisGreaves
PlutoniumLounger
Posts: 15498
Joined: 24 Jan 2010, 23:23
Location: brings.slot.perky

Re: Table of Contents anomaly in "Hyperlink Base"

Post by ChrisGreaves »

Hans> Keep in mind that ThisDocument and ThisWorkbook refer to the document/workbook that contains the code, not necessarily to the active document/workbook.

Thanks Hans. Too, I notice that if one were writing a bit of VBA code to handle this stuff one might want to specify whether “relative” referred to This Document or Curr Dir.

Jay> In Word 2003 and later (I tested in 2003 and the latest Microsoft 365), this works too:
ActiveDocument.BuiltInDocumentProperties(wdPropertyHyperlinkBase) = . . .
The constant wdPropertyHyperlinkBase has the decimal value 29. This is discoverable by opening the Object Browser (F2) and using its search box to look for "hyperlinkbase".

Thank you, Jay. Your comment sent me back to my code where I found that single-stepping through the code below worked every time (Alt-Tab and File Properties to inspect at each step).

Code: Select all

Sub test()
    ActiveDocument.BuiltInDocumentProperties(wdPropertyHyperlinkBase) = "JayFreedman"
    ActiveDocument.BuiltInDocumentProperties(29) = "Jay"
    ActiveDocument.BuiltInDocumentProperties("Hyperlink Base") = "Freedman"
End Sub
I have no idea why my original little test (("Hyperlink Base") =) failed to work; that it does so now I shall leave alone.

Cheers
Chris
An expensive day out: Wallet and Grimace