#1
|
|||
|
|||
How to create a special TOC in word document?
have a large number of Word documents, and need to divide each document into parts. What I am doing is to manually insert into the text the part splitting phrases, such as:
Part_1 Text goes here... Part_2 Text goes here... Part_3 Text goes here... I want to automate with VBA the task to create a TOC of all these splitting phrases at the beginning of the Word document. Perhaps applying a unique style to these splitters, and then create a TOC for this special style only? I appreciate it very much if anyone can help. |
#2
|
|||
|
|||
You could create a style say called "SpecTOC" and apply it to you separator phrases. Then run:
Code:
Sub ScratchMacro() 'A basic Word macro coded by Greg Maxey Dim oRng As Word.Range Set oRng = ActiveDocument.Range oRng.Collapse With ActiveDocument .TablesOfContents.Add Range:=oRng, RightAlignPageNumbers:= _ True, UseHeadingStyles:=False, IncludePageNumbers:=True, AddedStyles _ :="SpecTOC,1", UseHyperlinks:=True, HidePageNumbersInWeb:=True, _ UseOutlineLevels:=False .TablesOfContents(1).TabLeader = wdTabLeaderDots .TablesOfContents.Format = wdIndexIndent End With End Sub |
#3
|
|||
|
|||
Thanks!
The only issue with this method is that if you have a lot styles, some other styles may also be included in the TOC in addition to your style. The headings are excluded (as False), but there seems no way to exclude other styles.
|
#4
|
||||
|
||||
Perhaps you should try the code Greg supplied before inventing new issues. Other styles will need to be explicitly put into the TOC if you want them there so if those other styles don't get a mention in the AddedStyles attribute then you shouldn't start worrying about them.
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
#5
|
|||
|
|||
Thanks.
Thanks. I wouldn't say there is an issue if it is not actually what happens. I already used the same method as Greg Maxey's, and for some documents, ended up with a TOC of various styles (except for headings).
|
#6
|
|||
|
|||
I figured out a way
I used TC entries instead, and it works very well.
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
How do I create an index of every word in a document? | jbengal | Word | 5 | 11-23-2022 02:17 PM |
How to Create Dynamic Paragraphs in Word Document | gt7586d | Word | 3 | 02-19-2015 01:02 PM |
Create a word document by answering questions? | mattfrack | Word | 1 | 01-09-2015 02:25 PM |
How to identify whether Word 2007 was used to create a document saved as Word 2003 | noviceatwork | Word | 0 | 03-08-2012 06:40 AM |
Creating a special Document | darka5sa5sin | Word | 0 | 02-06-2009 11:23 AM |