#1
|
|||
|
|||
Table of Contents Hyperlinks
I have created a table of contents in Word 2011 and I do not use page numbers so I create hyperlinks for each toc entry to their respective location in the book.
This takes FOREVER to do and when I update the toc it STRIPS all the hyerlinks out of my toc. This is a royal pain!!!! Is there a way to preserve toc hyperlinks and bookmarks when you update the toc? Thanks!!! |
#2
|
||||
|
||||
Why are you manually creating hyperlinks? By default, a Word TOC functions as hyperlinks without all that extra work. If you prefer a hyperlink format, that's just a matter of choosing the appropriate options when creating the TOC.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#3
|
|||
|
|||
Perhaps I didn't explain myself properly.
Yes, Word can auto generate a toc with hyperlinks. However, if you remove the page numbers you also remove the hyperlinks. The real issue here - Is there a way to auto generate a toc with hyperlinks and no page numbers? |
#4
|
||||
|
||||
That is easily done, by using the \n switch in the TOC field code. For example, if you select the TOC and press Shift-F9, you might see:
{TOC \h \z \u} Simply add the \n switch, thus: {TOC \h \z \u \n} then press F9 to update the field.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#5
|
|||
|
|||
Paul I was pretty excited when I saw your solution, however, I forgot to mention I'm on a Mac and for some reason Microsoft does not treat switching the same on a Mac as it does on a PC.
Darn! |
#6
|
||||
|
||||
So what happens on a Mac with the \n switch?
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#7
|
|||
|
|||
Absolutely nothing.
It's weird... |
#8
|
|||
|
|||
This is a book for Kindle and I was just notified by the Kindle tech team the only way to make my Word toc hyperlinks is to completely finish the book and then go back and use bookmarks and hyperlinks to rebuild the entire toc (individually).
YIKES! That is exactly what I was trying to avoid. Bad part is if you "update " the toc Word kills all the bookmarks and hyperlinks in the toc and you have to start all over... |
#9
|
||||
|
||||
OK, so hiding the page #s isn't going to do what you need anyway.
In that case, what you probably need is a macro like the following to convert the TOC to hyperlinks. Do note, though, that hyperlinks don't update the way TOC fields do, so it's probably best to not do the conversion until the document is otherwise finalised. Code:
Sub ConvertTOC2Hyperlinks() Dim RngTOC As Range, RngItem As Range, StrBkMkList As String, StrTmp As String, i As Long With ActiveDocument With .TablesOfContents(1) .Update For i = 2 To .Range.Fields.Count StrBkMkList = StrBkMkList & "|" & Split(Trim(.Range.Fields(i).Code.Text), " ")(1) Next Set RngTOC = .Range End With RngTOC.Fields.Unlink For i = 1 To UBound(Split(StrBkMkList, "|")) Set RngItem = RngTOC.Paragraphs(i).Range RngItem.End = RngItem.End - 1 StrTmp = Replace(Split(StrBkMkList, "|")(i), "Toc", "HL") .Bookmarks.Add Name:=StrTmp, Range:=.Bookmarks(Split(StrBkMkList, "|")(i)).Range .Bookmarks(Split(StrBkMkList, "|")(i)).Delete .Hyperlinks.Add Anchor:=RngItem, SubAddress:=.Bookmarks(StrTmp).Range, _ TextToDisplay:=.Bookmarks(StrTmp).Range.Text Next End With End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#10
|
|||
|
|||
Paul,
Thank you for hanging in there with me - I really appreciate your efforts! I'm new to Word and I'm unclear as to how to add this macro. |
#11
|
||||
|
||||
For Mac macro installation & usage instructions, see: http://word.mvps.org/Mac/InstallMacro.html
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#12
|
|||
|
|||
Paul,
All is well now. Thank you for hanging in there!!! |
Tags |
table of contents, toc, toc hyperlinks |
Thread Tools | |
Display Modes | |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
hyperlinks in a table | eNGiNe | Word | 10 | 12-05-2012 04:02 PM |
Table of Contents | Shakes | Word | 2 | 10-24-2012 08:21 AM |
How to keep hyperlinks when creating a table of contents | Abacaxi | Word | 3 | 04-18-2012 12:24 AM |
VBA and hyperlinks in table cells | viuf | PowerPoint | 13 | 02-19-2012 10:34 AM |
Word with frames, table of contents, and hyperlinks to html | NHMC | Word | 0 | 12-09-2009 12:54 PM |