G
Guest
--
ElkeAdams
ElkeAdams
Sub MarkTOC()
Dim par As Paragraph
Dim f As Field
ActiveDocument.ActiveWindow.View.ShowAll = True
For Each f In ActiveDocument.Fields
If f.Type = wdFieldIndexEntry Then
f.Delete
End If
Next
For Each par In ActiveDocument.Paragraphs
If par.Style = "Heading 2" Then
par.Range.Select
Selection.Collapse (wdCollapseStart)
newField = ActiveDocument.Fields.Add(Selection.Range, _
wdFieldIndexEntry, """" & Left(par.Range.Text, Len(par.Range.Text) - 1) & """", False)
End If
Next
ActiveDocument.ActiveWindow.View.ShowAll = False
ActiveDocument.Fields(1).Update
For Each f In ActiveDocument.Fields
If f.Code = " XE """" " Then
f.Delete
End If
Next
Selection.HomeKey wdStory
End Sub
On further investigation it seems that Microsoft in their infinite wisdom also remove the hyperlinks so you can only manually go to the page - you have a static TOC.you will have an alphabetised toc with page numbers
e
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.