Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #4  
Old 07-01-2016, 04:11 PM
Guessed's Avatar
Guessed Guessed is offline Code to creating a custom TOC including too many styles Windows 10 Code to creating a custom TOC including too many styles Office 2013
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 4,176
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

Your code doesn't work the way it should because it doesn't correspond to the way that Word works.
Looking at each line, this is where you are having problems

Line 1 produces a field code that looks like this
TOC \o "1-9" \h \z \t "Heading 1,Heading 2"
So your Heading 1 and Heading 2 entries appear in the TOC because of the \o "1-9" part. Using the \t switch is superfluous in this case because those two styles are already in there. Also "Heading 1,1,Heading 2,2" is what is supposed to be in the quotes - you have to tell Word what TOC style to assign to each style.

Line 2 doesn't align with how tab leaders work.
.TablesOfContents(1).TabLeader = wdTabLeaderDots
A tab leader is a property of a particular tab in a particular paragraph or style. In the context of an entire table of contents which could contain 9 styles and many paragraphs this line means nothing. Plus the first table of contents in a document may not actually BE the TOC that you just inserted in the first line (if there is another TOC earlier in the doc).

Line 3
.TablesOfContents.Format = wdIndexIndent
I have no idea of what you expected to happen with this line. wdIndexIndent is a built-in constant with a value of 0. What does it mean to set a "Format = 0" when Format might be typeface/font size/bold/italic/paragraph spacing/paragraph indent etc. And where are you trying to apply this 'formatting'?
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Code to creating a custom TOC including too many styles 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
Code to creating a custom TOC including too many styles Creating Styles Template? Stone Word 2 09-11-2012 04:54 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 01:41 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft