Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Adding hyperlinks in a manual TOC in word 2010

Posted on 2013-11-06
8
Medium Priority
?
420 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 33

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
Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

 
LVL 33

Accepted Solution

by:
Paul Sauvé earned 2000 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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

A few years ago I was very much a beginner at VBA, and that very much remains the case today.  I'll do my best to explain things as I go in the hope that other beginners can follow.  If you just want to check out a tool that creates a Select Case fu…
This article describes how to use the Send to Mail Recipient command. The instructions apply generally to Office 2007 and later versions, but Microsoft® Word 2013 was used for the specific steps and figures.  What is Send to Mail Recipient? Send…
This video walks the viewer through the process of creating a watermark for their document, customizing it, and saving it for viewing/printing needs.
This video shows where to find the word count, how to display it, and what it breaks down to in Microsoft Word.
Suggested Courses

886 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