Solved

Adding hyperlinks in a manual TOC in word 2010

Posted on 2013-11-06
8
397 Views
Last Modified: 2013-11-21
Hi EEE,

  I have a word doc 2010. I have a manual TOC set up and needed to hyperlink the titles involved in the toc to relevant sections of the doc. How can I accomplish this?

I dont want to do an auto TOC as it will involve a lot of work at this point.

Thx
0
Comment
Question by:LuckyLucks
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
8 Comments
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 39628702
What do you mean by 'a manual TOC'? Can you post a sample document, please?
0
 
LVL 32

Expert Comment

by:Paul Sauvé
ID: 39628841
I think you have to use bookmarks!
Insert tab -> Links -> Bookmark

Go to each title and insert a bookmark with a unique name (alphanumeric, no spaces, can't START with a number - ex.: name1, NOT 1name, NOT name 1, NOT name.1).

Go back to the manual TOC and insert a hyperlink (Insert tab -> Links -> Hyperlink) in each title. Select the entire line!

Select the Place in This Document in the options list on the left-hand side of the and choose the Bookmark name corresponding to the place in the document you inserted it in.

Here is an example.
Manual-TOC.docx
0
 
LVL 15

Expert Comment

by:DrTribos
ID: 39629632
It is hard to imagine how using an auto TOC could be MORE work... worst case scenario is heading styles have not been used?  

For the time taken to manually add each link I'd put my money on applying the heading styles manually... and creating the TOC automatically.  Failing that, I 2nd Graham's call for a sample doc!
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
LVL 32

Accepted Solution

by:
Paul Sauvé earned 500 total points
ID: 39630499
DrTribos is, of course, correct! But I DID want to answer LuckyLucks' question.

Instead of putting a bookmark at every paragraph you want in the TOC, simply change the paragraph style to Heading 1, Heading 2, Heading 3, ... and generate the TOC automatically! That way, if you modify the document, you simply regenerate or update the TOC. :-)

That's why we use Word!
0
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 39630626
Yes the built-in TOC functionality in Word is much easier, but here is some VBA code that sketches out a method for doing what you ask.

It assumes that your TOC is a block of text paragraphs at the start of the document, and that the block is contained in a bookmark named MyToc.

It looks for the first occurrence after the TOC of each piece of text. It bookmarks that location and turns the TOC entry into a hyperlink to the bookmark.
Sub MakeHyperLinks()
    Dim Para As Paragraph
    Dim rngPara As Range
    Dim rngContent As Range
    Dim iBmkNumber As Integer
    
    For Each Para In ActiveDocument.Bookmarks("MyToc").Range.Paragraphs
        Set rngPara = Para.Range
        rngPara.MoveEnd wdCharacter, -1 'drop paragraph mark
        Set rngContent = ActiveDocument.Range
        rngContent.Start = rngPara.End + 1
        iBmkNumber = iBmkNumber + 1
        With rngContent.Find
            .Text = rngPara.Text
            If .Execute Then
                ActiveDocument.Bookmarks.Add "bmkTocEntry" & iBmkNumber, rngContent
                ActiveDocument.Hyperlinks.Add rngPara, , "bmkTocEntry" & iBmkNumber, , rngPara.Text
            End If
        End With
    Next Para
End Sub

Open in new window

0
 
LVL 15

Expert Comment

by:DrTribos
ID: 39632219
Paulsauve - Agreed. Important to answer the users question... Sometimes I have asked similar questions.  More than once I've felt the need to do things differently to 'how Word works' (other times I was simply unaware of what Word can do).  Still... hard to imagine, I'd be curious to see a sample.

Going down the 'how Word works' path... an alternate approach could be an adaptation of Grahams code to search for matching text based on the TOC and applying the appropriate heading style in the document...

I assume that would be an acceptable amount of work?
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction Authors who set out to write any sort of lengthy piece for online submission—be it a long question or comment on a technical form, an article, or a substantial blog entry—often find it useful to work up a draft in an editor other t…
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
This video shows where to find the word count, how to display it, and what it breaks down to in Microsoft Word.
This Experts Exchange video Micro Tutorial shows how to tell Microsoft Office that a word is NOT spelled correctly. Microsoft Office has a built-in, main dictionary that is shared by Office apps, including Excel, Outlook, PowerPoint, and Word. When …
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question