![]() |
|
#1
|
|||
|
|||
|
Hi all,
I have a word document with table of contents. However, after I convert the Word Doc file to PDF, the Table of Content list is un-clickable in the PDF. How can I make the index list clickable in PDF? I have an Office 365 subscription and am using Microsoft Word on my MAC. Thanks in advance! |
|
#2
|
||||
|
||||
|
Word for Mac uses OS X's built-in PDF creator, which doesn't do what you want. Word for Windows uses either Adobe's PDF creator or its own (depending on the Word version), and either of those will create a document with working Table of Contents links.
The following macro converts a Table of Contents to Hyperlinks (with or without page #s). IIRC, 'proper' hyperlinks survive the Mac conversion process. Since hyperlinks don't update the way TOC fields do, it's probably best to not do the conversion until the document is otherwise finalised. 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
With RngItem
.MoveEndUntil vbTab, wdBackward
.End = .End - 1
End With
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:=StrTmp, TextToDisplay:=.Bookmarks(StrTmp).Range.Text
' Delete the next 2 lines to omit page #s
Set RngItem = RngTOC.Paragraphs(i).Range.Words.Last.Previous.Words.First
.Hyperlinks.Add Anchor:=RngItem, SubAddress:=StrTmp, TextToDisplay:=RngItem.Words.Last
RngItem.Paragraphs.First.Range.Font.Reset
Next
End With
End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
#3
|
|||
|
|||
|
Thanks Paul.
|
|
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Turn Word table cell into clickable hyperlink button | cobms2014 | Word | 3 | 03-26-2015 09:10 AM |
| Word 07 won't create clickable links sometimes | baffled | Word | 4 | 01-08-2014 10:53 PM |
| Links need to be Hot links in Bibliography in Word 2010, 2013 | synses | Word | 1 | 11-23-2013 12:48 AM |
| Clickable Links Converted to hyperlink texts automatically when I open a word doc | Kingsly | Word | 2 | 09-13-2012 10:42 AM |
Clickable button in word
|
ndjustin20 | Word VBA | 1 | 02-08-2012 02:50 PM |