Solved

Adding hyperlinks in a manual TOC in word 2010

Posted on 2013-11-06
8
389 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 31

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 14

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
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
LVL 31

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 14

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

A Knowledge Base That Stays Up-to-Date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Google Docs 3 61
Renumber Word data 5 46
VBA code snippets in a Word 2016 document 3 49
MailMerge VBA DataSource Connection Issue 10 34
Like many others, we try and discourage users from printing documents unnecessarily and instead send or share them electronically. However, this doesn't always work and documents are still printed. With this simple solution, if the user tries to …
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 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…
In a previous video Micro Tutorial here at Experts Exchange (http://www.experts-exchange.com/videos/1358/How-to-get-a-free-trial-of-Office-365-with-the-Office-2016-desktop-applications.html), I explained how to get a free, one-month trial of Office …

760 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now