![]() |
|
|
|
#1
|
|||
|
|||
|
Hi,
I'm new to this forum, and have a question I'm hoping you can help me with? I've a lengthy .DOCX document which is a software manual. I'd like to create a table/list of bookmarks at the beginning of the document, so that my support team can click on an issue (in the form of a bookmark) and go to that point in the manual, where they can then read out the solution. I have the bookmarks created, I now need a means of creating a list of them so that they can be clicked on to hyperlink to the correct location. Many thanks in anticipation, David |
|
#2
|
||||
|
||||
|
The following should do the trick.
Code:
Option Explicit
Sub AddBookmarkList()
Dim oBM As Bookmark
Dim oTable As Table
Dim i As Long
Dim oRng As Range
Set oRng = ActiveDocument.Range(0, 0)
Set oTable = oRng.Tables.Add(oRng, 1, 1)
For i = 1 To ActiveDocument.Bookmarks.Count
Set oBM = ActiveDocument.Bookmarks(i)
ActiveDocument.Hyperlinks.Add _
Anchor:=oTable.Cell(i, 1).Range, Address:="", _
SubAddress:=oBM.Name, _
ScreenTip:="", _
TextToDisplay:="Goto Bookmarked Location " & oBM.Name
If i < ActiveDocument.Bookmarks.Count Then
oTable.Rows.Add
End If
Next i
lbl_Exit:
Set oTable = Nothing
Set oBM = Nothing
Set oRng = Nothing
Exit Sub
End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
|
#3
|
|||
|
|||
|
Thanks Graham - works a treat!
David |
|
#4
|
|||
|
|||
|
Sounds rather like a table of contents, though I could be missing something …
|
|
#5
|
|||
|
|||
|
Sounds like a Table of Contents to me, as well. That would be much easier since the feature is built-in.
Generating a Table of Contents - Complex Documents How to create a table of contents in Microsoft Word by Shauna Kelly (Just because you use the TOC feature does not mean that you have to call it a Table of Contents in your document.) |
|
#6
|
||||
|
||||
|
See also the code I posted at: https://social.msdn.microsoft.com/Fo...?forum=worddev . That code outputs both a table of bookmarks and a table of cross-references to them.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
| Tags |
| bookmark list |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Create Index List Using Bookmarks in Alphabetical Order | priteshp108 | Word VBA | 8 | 11-16-2015 12:06 PM |
Form updating Bookmarks - writes to the bookmarks multiple times
|
PeterPlys | Word VBA | 13 | 01-14-2015 06:41 AM |
Macro to list all bookmarks
|
Marrick13 | Word VBA | 4 | 02-09-2012 08:00 PM |
| How to fix "create bookmarks using headings" as default when saving to PDF using Word | ghumdinger | Word | 0 | 05-05-2011 02:11 AM |
| How do you create a list similar to an itunes list? | hatemail13 | Excel | 1 | 08-06-2010 02:21 AM |