#1
|
|||
|
|||
Create Index List Using Bookmarks in Alphabetical Order
Hello, everyone. I have a dilemma. I need to create an index of over 1700 songs by alphabetical order, where the index entries (which are the song titles) have to be hyperlinked to the particular song in the word document. I have manually added all the index entries (song titles) but the index entries are not hyperlinked so they won't go to the particular song when clicked on. So when I generate the PDF, it won't go there.
However, I have also started to bookmark the song titles, where the bookmark names are A_1, A_2, A_3, A_4, etc. Then when I cross-reference the index entries to the bookmark name, the index entries in the PDF does go to the particular song. However, I'm trying to save manual work with a macro. Can anyone help me with this macro. I did write a macro but the entries were not alphabetized. Instead the order was A_1, A_2, etc instead of the song title itself. |
#2
|
||||
|
||||
Is there a reason for not using a Table of Contents?
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#3
|
|||
|
|||
Yes. TOC gives you list that is not alphabetized. I do have a TOC but it is to organize the type of songs, since they are divided in sections. Each song is listed in TOC but it is not alphabetical hence one cannot find the song quickly without an alphabetic list like in an index.
|
#4
|
||||
|
||||
Do your titles use Word's Heading Styles? If so, which?
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#5
|
|||
|
|||
It's a TOC level 2 if that's what your asking. Otherwise, I've defined a style called "Kirtan Title" for all the titles of the songs.
|
#6
|
|||
|
|||
What would be ideal is a macro that spits out the bookmarked entries in alpha order and links to that part of document without an index.
I have all titles bookmarked with names of the bookmarks as A_1, A_2, .... A_1750. Those entries to point to song titles. So the title has to be alphabetical order. Like this Index ------ AAA is a song... 1 (bookmark name A_5) BBB is a song ... 1 (bookmark name A_8) CCC is a songs ... 2 (bookmark name A_1750) ......... ZZZ is a song .... 567 (bookmark name A_10) etc. so bookmark names are random when song titles are concerned. |
#7
|
|||
|
|||
Ok here is the macro that lists all the "bookmarked text" as cross-references.
I just need this list in alphabetical order by the **bookmarked text** instead of the **bookmark name**. Again the bookmark names are A_1, A_2, etc. The bookmarked text is the actual song title. If you can help me with that, I would be very grateful. Code:
Sub write_all_Cross_Refs() Dim bkMark As Bookmark Dim strMarks() As String Dim intCount As Integer If ActiveDocument.Bookmarks.Count > 0 Then ReDim strMarks(ActiveDocument.Bookmarks.Count - 1) intCount = 0 For Each bkMark In ActiveDocument.Bookmarks Selection.InsertCrossReference ReferenceType:="Bookmark", ReferenceKind:= _ wdContentText, ReferenceItem:=bkMark.Name, InsertAsHyperlink:=True, _ IncludePosition:=False, SeparateNumbers:=False, SeparatorString:=" " intCount = intCount + 1 Next bkMark End If End Sub |
#8
|
||||
|
||||
Try:
Code:
Sub MakeHyperlinks() Application.ScreenUpdating = False Dim oBkMrk As Bookmark, TblRng As Range, HLnkRng As Range, StrTxt As String, HLnk As Hyperlink With ActiveDocument.Range .InsertAfter vbCr Set TblRng = .Characters.Last Set HLnkRng = .Characters.Last For Each oBkMrk In .Bookmarks With oBkMrk StrTxt = .Range.Text & vbTab & .Name End With With HLnkRng .Collapse wdCollapseEnd .Text = Split(StrTxt, vbTab)(0) Set HLnk = .Hyperlinks.Add(Anchor:=HLnkRng, SubAddress:=Split(StrTxt, vbTab)(1), _ TextToDisplay:=Split(StrTxt, vbTab)(0)) .End = HLnk.Range.End + 1 .InsertAfter vbCr End With Next oBkMrk With TblRng .ConvertToTable Separator:=vbTab With .Tables(1) .Sort .ConvertToText End With End With End With Set HLnk = Nothing: Set TblRng = Nothing: Set HLnkRng = Nothing Application.ScreenUpdating = True End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#9
|
|||
|
|||
Thanks, man! I cannot make one bit sense of that but it works. It's exactly what I wanted. You saved me hours of work.
It took a long time since I have over 1700 songs but it finally did it. |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
List Style Numbering picks up out of order number from LATER list | spthomas | Word | 12 | 12-16-2013 05:23 PM |
Alphabetical Sort - result not alphabetical! | hanvyj | Excel | 3 | 10-14-2013 10:59 PM |
O 2007 folders & files lose alphabetical order in | John Seed | Outlook | 0 | 02-28-2012 05:56 PM |
Find in alphabetical order list | 14spar15 | Word | 1 | 12-03-2011 03:01 PM |
Some contacts are not in alphabetical order in Outlook 2007 | marko959 | Outlook | 0 | 04-21-2011 01:49 PM |