![]() |
|
|
|
#1
|
|||
|
|||
|
I'm trying to write code to insert a custom table of contents. The code first writes "Table of Contents" in a new paragraph and sets that paragraph to a style other than Heading 1 or Heading 2 (though it is based on Heading 1).
Then I try this: Code:
With ActiveDocument
.TablesOfContents.Add Range:=Selection.Range, RightAlignPageNumbers:= _
True, UseHeadingStyles:=False, IncludePageNumbers:=True, AddedStyles _
:="Heading 1,Heading 2", UseHyperlinks:=True, _
HidePageNumbersInWeb:=True, UseOutlineLevels:=False
.TablesOfContents(1).TabLeader = wdTabLeaderDots
.TablesOfContents.Format = wdIndexIndent
End With
What am I missing? (FWIW, if I turn on the macro recorder and insert a TOC that correctly excludes the TOC style, I get exactly what I want, and I get almost exactly the code above. The only difference is that the recorder writes Code:
AddedStyles:="Heading 1, 1, Heading 2, 2" |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
How to create custom table styles?
|
Pey1 | PowerPoint | 1 | 05-25-2016 02:15 AM |
| Styles in a Custom Ribbon | inagalaxyfarfarawry | Word | 5 | 12-15-2015 11:18 AM |
| Custom Bar Styles | dbsoccer | Project | 7 | 10-31-2013 07:26 AM |
| creating new styles | hannu | Word | 8 | 04-28-2013 11:23 PM |
Creating Styles Template?
|
Stone | Word | 2 | 09-11-2012 04:54 PM |