Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 03-28-2017, 12:50 PM
cranz cranz is offline Clickable TOC links - Word to PDF Mac OS X Clickable TOC links - Word to PDF Office 2016
Novice
Clickable TOC links - Word to PDF
 
Join Date: Mar 2017
Posts: 2
cranz is on a distinguished road
Default Clickable TOC links - Word to PDF

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!
Reply With Quote
  #2  
Old 03-28-2017, 05:10 PM
macropod's Avatar
macropod macropod is offline Clickable TOC links - Word to PDF Windows 7 64bit Clickable TOC links - Word to PDF Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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]
Reply With Quote
  #3  
Old 03-29-2017, 09:03 AM
cranz cranz is offline Clickable TOC links - Word to PDF Mac OS X Clickable TOC links - Word to PDF Office 2016
Novice
Clickable TOC links - Word to PDF
 
Join Date: Mar 2017
Posts: 2
cranz is on a distinguished road
Default

Thanks Paul.
Reply With Quote
Reply



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 TOC links - Word to PDF Clickable button in word ndjustin20 Word VBA 1 02-08-2012 02:50 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 12:38 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft