Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / January 2005

Tip: Looking for answers? Try searching our database.

Index from Titles

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Volker Schubert - 17 Jan 2005 12:07 GMT
Hi,
I've made a songbook in MS Word consisting of the lyrics of several songs. The songs themselves are arranged by genre, e.g. rock songs, folk songs, etc.. The titles of the songs are formatted in a special header style.
What I'd like to do is to automatically generate index entries (i.e. XE fields) for the title headers. I.e., whereever the special header style is found, an index entry with the header text should be generated.

Has anybody some idea how this could be accomplished?

Thanks in advance,
 Volker
Greg Maxey - 17 Jan 2005 13:20 GMT
Volker,

Maybe something like this (change Heading 1 to our title style name):

Sub IndexHeadingSytle()
Dim oFld As Field
Dim oPara As Paragraph
Dim myRange As Range
Dim oDoc As Document

Set oDoc = ActiveDocument
With ActiveWindow.View
 .ShowFieldCodes = False
 .ShowHiddenText = False
 .ShowAll = False
End With
'Prevent double indexing
For Each oFld In oDoc.Fields
 If oFld.Type = wdFieldIndexEntry Then oFld.Delete
Next

For Each oPara In oDoc.Paragraphs
Set myRange = oPara.Range
If oPara.Style = "Heading 1" Then
 Set myRange = oPara.Range
 oDoc.Indexes.MarkEntry Range:=myRange, Entry:=Trim(myRange.Text)
End If
Next oPara

End Sub

Signature

Greg Maxey/Word MVP
A Peer in Peer to Peer Support

> Hi,
> I've made a songbook in MS Word consisting of the lyrics of several
[quoted text clipped - 9 lines]
> Thanks in advance,
>  Volker
Volker Schubert - 18 Jan 2005 12:40 GMT
Hi Greg,

this works great!

Thanks a lot! I would have wasted hours by doing that manually.

Volker
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.