PDA

View Full Version : [SOLVED:] Word TOC required for large number of custom heading styles



VidarParry
08-25-2016, 08:46 PM
Hi all,
First posting here, so I hope you can help me out.

I consider myself an advanced Excel and Word user and I dabble in VBA to fix various things.

I’m using Microsoft Office 365 and in particular for this question Word 16.0.7070.2833 (but it seems to be the same problem in all Word versions!)

I have a rather large document template that comprises around 50 different ‘chapters’, each requiring a unique prefix to the paragraph numbering that is independent of the other chapters. Users delete and amend the chapters to suit their particular needs, and make a final document with a single TOC. Unfortunately the document is confidential so I can’t share it.

We have previously had significant issues with formatting when documents created using previous templates used any in-built Word styles, so each chapter has a unique set of level 1 to 9 numbering styles, all based on a “nostyles” base. Unintended consequence - This means they are not linked to Heading 1, Heading 2 etc so the standard 2 level TOC feature doesn’t work.

What I need is a Table of Contents that includes all the ‘custom’ level 1 and 2 styles – seems easy huh!

Unfortunately, there seems to be a limit to the number of entries in a TOC field, and the TOC basically truncates at various points.

What I’m seeking I suspect is not achievable other than using VBA (which is what led me here!) BUT if anyone has suggestions on fixing it without VBA I’m all ears!

As an example, I’ve tried the TOC field as follows:
{TOC \h \z \t "ABC_Test(H): C1 2,2,ABC_Test(H): C2 1,1,ABC_Test(H): C2 2,2,ABC_Test(H): M01 1,1,ABC_Test(H): M01 2,2,ABC_Test(H): M02 1,1,ABC_Test(H): M02 2,2,ABC_Test(H): M03 1,1,ABC_Test(H): M03 2,2,ABC_Test(H): M04 1,1,ABC_Test(H): M04 2,2,ABC_Test(H): M05 1,1,ABC_Test(H): M05 2,2,ABC_Test(H): M06 1,1,ABC_Test(H): M06 2,2,ABC_Test(H): M07 1,1,ABC_Test(H): M07 2,2,ABC_Test(H): M08 1,1,ABC_Test(H): M08 2,2,ABC_Test(H): M09 1,1,ABC_Test(H): M09 2,2,ABC_Test(H): M10 1,1,ABC_Test(H): M10 2,2,ABC_Test(H): M11 1,1,ABC_Test(H): M11 2,2,ABC_Test(H): M12 1,1,ABC_Test(H): M12 2,2,ABC_Test(H): M13 1,1,ABC_Test(H): M13 2,2,ABC_Test(H): M14 1,1,ABC_Test(H): M14 2,2,ABC_Test(H): MO10 1,1,ABC_Test(H): MO10 2,2,ABC_Test(H): S01 1,1,ABC_Test(H): S01 2,2,ABC_Test(H): S02S 1,1,ABC_Test(H): S02S 2,2,ABC_Test(H): S03 1,1,ABC_Test(H): S03 2,2,ABC_Test(H): S04 1,1,ABC_Test(H): S04 2,2,ABC_Test(H): S05 1,1,ABC_Test(H): S05 2,2,ABC_Test(H): S06S 1,1,ABC_Test(H): S06S 2,2,ABC_Test(H): S07 1,1,ABC_Test(H): S07 2,2,ABC_Test(H): S07S 1,1,ABC_Test(H): S07S 2,2,ABC_Test(H): S08 1,1,ABC_Test(H): S08 2,2,ABC_Test(H): S09 1,1,ABC_Test(H): S09 2,2,ABC_Test(H): S10 1,1,ABC_Test(H): S10 2,2,ABC_Test(H): S11 1,1,ABC_Test(H): S11 2,2,ABC_Test(H): S12 1,1,ABC_Test(H): S12 2,2,ABC_Test(H): S13S 1,1,ABC_Test(H): S13S 2,2,ABC_Test(H): S14 1,1,ABC_Test(H): S14 2,2,ABC_Test(H): S15 1,1,ABC_Test(H): S15 2,2,ABC_Test(H): S16 1,1,ABC_Test(H): S16 2,2,ABC_Test(H): S17 1,1,ABC_Test(H): S17 2,2,ABC_Test(H): S18 1,1,ABC_Test(H): S18 2,2,ABC_Test(H): S19 1,1,ABC_Test(H): S19 2,2,ABC_Test(H): S30 1,1,ABC_Test(H): S30 2,2,ABC_Test(H): S30S 1,1,ABC_Test(H): S30S 2,2,ABC_Test(H): S31S 1,1,ABC_Test(H): S31S 2,2,ABC_Test(H): S32 1,1,ABC_Test(H): S32 2,2,ABC_Test(H): S33 1,1,ABC_Test(H): S33 2,2,ABC_Test(H): S34 1,1,ABC_Test(H): S34 2,2,ABC_Test(H): S35 1,1,ABC_Test(H): S35 2,2,ABC_Test(H): S36 1,1,ABC_Test(H): S36 2,2,ABC_Test(H): S37 1,1,ABC_Test(H): S37 2,2,ABC_Test(H): S38 1,1,ABC_Test(H): S38 2,2,ABC_Test(H): S39 1,1,ABC_Test(H): S39 2,2,ABC_Test(H): S40 1,1,ABC_Test(H): S40 2,2,ABC_Test(H): Title,1"}

With the current template content, the generated TOC stops at about the end of chapter MO4 (ie styles ABC_Test(H): M04 1,1 and ABC_Test(H): M04 2,2). From experimentation, the stopping point always seems to be near the style that is around the 240-250 character point in the TOC field.

I’ve tried bookmarking each chapter and then including the specific styles for that chapter, and that kinda works but is very tedious. I can also see problems with users who don’t understand Word messing with the Bookmarks accidentally or otherwise, as well as for maintenance of the template (which may not be done by experienced Word people).

So, all and any ideas gratefully received – I’m pulling my hair out!
Thanks in Advance:-)

Cheers
…Steve

Paul_Hossler
08-27-2016, 07:00 AM
Maybe multiple TOC fields one after the other broken by area or topic ???? This is just a quick edit




{TOC \h \z \t "ABC_Test(H): C1 2,2,ABC_Test(H): C2 1,1,ABC_Test(H): C2 2,2,ABC_Test(H)"}

{TOC \h \z \t "M01 1,1,ABC_Test(H): M01 2,2,ABC_Test(H): M02 1,1,ABC_Test(H): M02 2,2,ABC_Test(H): M03 1,1,ABC_Test(H): M03 2,2,ABC_Test(H): M04 1,1,ABC_Test(H): M04 2,2,ABC_Test(H): M05 1,1,ABC_Test(H): M05 2,2,ABC_Test(H): M06 1,1,ABC_Test(H): M06 2,2,ABC_Test(H): M07 1,1,ABC_Test(H): M07 2,2,ABC_Test(H): M08 1,1,ABC_Test(H): M08 2,2,ABC_Test(H): M09 1,1,ABC_Test(H): M09 2,2,ABC_Test(H): M10 1,1,ABC_Test(H): M10 2,2,ABC_Test(H): M11 1,1,ABC_Test(H): M11 2,2,ABC_Test(H): M12 1,1,ABC_Test(H): M12 2,2,ABC_Test(H): M13 1,1,ABC_Test(H): M13 2,2,ABC_Test(H): M14 1,1,ABC_Test(H): M14 2,2,ABC_Test(H): MO10 1,1,ABC_Test(H): MO10 2,2,ABC_Test(H)"}

{TOC \h \z \t "S01 1,1,ABC_Test(H): S01 2,2,ABC_Test(H): S02S 1,1,ABC_Test(H): S02S 2,2,ABC_Test(H): S03 1,1,ABC_Test(H): S03 2,2,ABC_Test(H): S04 1,1,ABC_Test(H): S04 2,2,ABC_Test(H): S05 1,1,ABC_Test(H): S05 2,2,ABC_Test(H): S06S 1,1,ABC_Test(H): S06S 2,2,ABC_Test(H): S07 1,1,ABC_Test(H): S07 2,2,ABC_Test(H): S07S 1,1,ABC_Test(H): S07S 2,2,ABC_Test(H): S08 1,1,ABC_Test(H): S08 2,2,ABC_Test(H): S09 1,1,ABC_Test(H)"}

{TOC \h \z \t "S09 2,2,ABC_Test(H): S10 1,1,ABC_Test(H): S10 2,2,ABC_Test(H): S11 1,1,ABC_Test(H): S11 2,2,ABC_Test(H): S12 1,1,ABC_Test(H): S12 2,2,ABC_Test(H): S13S 1,1,ABC_Test(H): S13S 2,2,ABC_Test(H): S14 1,1,ABC_Test(H)"}

VidarParry
08-27-2016, 06:38 PM
Thanks Paul,
Yes - I have tried that including broken up as you suggested, and they TOC fields are too long. It's looking like I'll have to do a TOC entry for each individual M and S 'chapter' (Bookmarking each whole chapter because the ABC_Test(H): Title,1 entry applies across the whole document and is needed as this is what the 'real' Heading 1 styles are).
Cheers
...Steve

VidarParry
09-01-2016, 12:33 AM
Well, after hours of research and playing, the fix I fell across accidentally is so simple.

For each of the custom 'heading' fonts you assign the requisite "Outline level" (level 1 to 9) in the paragraph formatting.

The standard basic TOC then works apparently without limitation.

Problem solved:-)

Cheers
...Steve

Paul_Hossler
09-04-2016, 08:05 AM
Well, after hours of research and playing, the fix I fell across accidentally is so simple.

For each of the custom 'heading' fonts you assign the requisite "Outline level" (level 1 to 9) in the paragraph formatting.

The standard basic TOC then works apparently without limitation.

Problem solved:-)

Cheers
...Steve


Darn -- I forgot all about that (I never had enough headings to have to do that)

Good solution

Now you need to write a macro to loop your styles and add the Outline Level based on the style name

VidarParry
09-04-2016, 12:49 PM
I just added the property to the style set creation macro I already had:-)
All so easy in hindsight:-)
Cheers
...Steve