#1
|
|||
|
|||
Formatting for internal hyperlinks question.
Hi All
I am trying to insert internal hyperlinks into a novel I've written, in order for readers to be able to navigate from the chapter headings in the contents section to the desired chapter (within an ebook). I highlighted the relevant chapter, clicked Add Bookmark, and then went to the chapter reference in the contents section and highlighted it, then clicked add Hyperlink. No problem - worked perfectly. The issue is a technical one about Kindle ebook previews, because in their previewer they have a dropdown menu which should (but in my case did not) include "contents". However, the real issue is a Word one, because I know there is another way to format a document with internal hyperlinks (other than the one I describe above) and I know that way works and gives me what I want in the Kindle previewer. So... can anyone help me with alternative ways to insert internal hyperlinks other than the way I describe above? Sincere thanks Regards R |
#2
|
||||
|
||||
A Table of Contents in Word automatically hyperlinks to the corresponding headings - provided you've set things up correctly. The simplest way to do the setup is to use Word's heading Styles; the Table of Contents (TOC) field automatically picks those up.
Accordingly, I don't follow what you mean by: Quote:
Since a Word Table of Contents won't work in the ebook format, what you could do is to use a Word Table of Contents for editing purposes and, when you're done convert it to hyperlinks, which is what the following macro does: 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 If InStr(.Range.Fields(1).Code.Text, "\n") = 0 Then For i = 3 To .Range.Fields.Count Step 2 StrBkMkList = StrBkMkList & "|" & Split(Trim(.Range.Fields(i).Code.Text), " ")(1) Next Else For i = 2 To .Range.Fields.Count StrBkMkList = StrBkMkList & "|" & Replace(Split(Trim(.Range.Fields(i).Code.Text), " ")(2), """", "") Next End If 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] |
#3
|
|||
|
|||
Hi Macro & many thanks for your reply.
To clarify the bit you say you don't understand - I literally just typed the document from start to finish, no formatting. Then typed a contents page at the start with a list of the chapters. Then simply connected the corresponding chapters to their counterparts in the contents page using the Bookmarks/Hyperlinks method I describe. So a very manual process in an unformatted document (which is why I guess it didn't work.) Macros are most definitely way over my head, as you can probably tell from the ham-fisted way I did my hyperlinks. So if you could dumb it down a bit I'd be grateful. R Last edited by macropod; 09-19-2015 at 10:39 PM. Reason: Deleted superfluous quote of entire post replied to |
#4
|
||||
|
||||
The first thing you need to learn about working with Word is how to use Styles properly. They make complex document construction and maintenance a snap. Start with:
http://www.addbalance.com/usersguide/styles.htm For a basic understanding of how a Word Table of Contents (TOC) field works with Word's Heading Styles, see the attachment at: https://www.msofficeforums.com/word/...html#post16114. Note how the Table of Contents also hyperlinks to the relevant headings. This is just one example of how using Styles facilitates document creation & management - edit/delete/add a heading, then preview the document and the Table of Contents updates itself!
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#5
|
|||
|
|||
Hi Paul
This is very helpful so thanks. I've had a read through and managed to set up a short test doc. where I used the Headings/Styles to create a TOC and it all worked very well, which I was happy with, except when I export to PDF they no longer work, and I know this means they will not work when I upload to Kindle either. Any ideas? Thanks, R Last edited by macropod; 09-19-2015 at 10:39 PM. Reason: Deleted superfluous quote of entire post replied to |
#6
|
||||
|
||||
Whether a Word Table of Contents works in a PDF depends on how the PDF conversion is done. Nevertheless, that's irrelevant for your purposes and it's also where the macro in post #2 comes into play.
PS: Please don't keep quoting entire previous posts in your replies. Doing so just adds clutter - only quote the bits that need to be quoted (if any).
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#7
|
|||
|
|||
Paul - I've got it nailed. My big mistake was presuming failure to export to PDF meant failure to export to Kindle (based on previous experience) but I managed to set up as per your advice and it transported into Kindle.
So, |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Page Number Formatting Question | Redgum | Word | 3 | 09-17-2015 04:08 PM |
Drop down menus colour formatting - Newbie question | TerryStevenson | Word | 2 | 09-17-2013 10:43 AM |
Conditional formatting question based on cell date | Cosmo | Excel | 2 | 04-08-2013 12:12 PM |
Formatting question... | rwear | Word | 1 | 01-30-2011 11:36 PM |
Excel 2007 - Question on conidial formatting? | jerrymbna22 | Excel | 2 | 03-24-2010 11:48 AM |