Solved

Adding hyperlinks in a manual TOC in word 2010

Posted on 2013-11-06
8
394 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
  • 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: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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.

 
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

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

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

If you work with Word a lot, you probably use styles. If you use styles a lot, you've probably balled your fist more often than not when working with the ribbon. In Word 2007/2010, one of the things that I find missing when using styles is a quic…
Introduction This tutorial provides instructions on how to properly format your Word document using the inbuilt tools provided. The benefits of using these tools means your documents are more accessible and easily portable to other applications an…
In this video, we show how to convert an image-only PDF file into a PDF Searchable Image file, that is, a file with both the image (typically from scanning) and text, which is created in an automated fashion with Optical Character Recognition (OCR) …
This video walks the viewer through the process of creating envelopes and labels, with multiple names and addresses. Navigate to the “Start Mail Merge” button in the Mailings tab: Follow the step-by-step process until asked to find the address doc…

820 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