-
Modifying Table of Contents with VBA
I have an Access database that uses VBA to produce a Word document with a Table of Contents. It works fine. Each State is a Heading 1, then locations under them are Heading 2.
Now the customer wants each State in the Table of Contents to start on a new page. I can't figure out how to get VBA to do that. Manually doing an insert page break in the TOC after the document is produced is not an option.
Here is the code I use to produce the TOC from Access and a picture of what the customer wants.
Thanks,
-------------------------------
Set myWordRange = WordApp.ActiveDocument.Range(0, 0)
'code to insert text "TABLE OF CONTENTS" above the actual TOC table
WordApp.ActiveDocument.TablesOfContents.Add myWordRange, _
UseFields:=False, _
UseHeadingStyles:=True, _
LowerHeadingLevel:=3, _
UpperHeadingLevel:=1, _
UseHyperlinks:=True
With WordApp.ActiveDocument
.TablesOfContents(1).Range.Font.Name = "Arial Narrow"
.TablesOfContents(1).Range.Font.Size = 11
.TablesOfContents(1).TabLeader = Word.WdTabLeader.wdTabLeaderDots
.TablesOfContents.Format = Word.WdTocFormat.wdTOCSimple
End With
--------------------------------------------------
TOC_Heading1_Mod.JPG
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules