In Word 365, can you specify alternative Heading styles when formatting page numbers using VBA?

168 Views Asked by At

Our organization has documents with appendices that have their own numbering scheme, separate from the main document, and to make this clear, we would like to have the appendix number precede the page number in the table of contents (e.g. A-1, A-2, B-1, C-1).

We have created an outline list style, ‘Appendices’, for appendix headings (A = Level 1, A.1 = Level 2, A.1.1 = Level 3, etc.) that map to styles (Appendix 1, Appendix 2, etc.), so ideally we’d like to specify this alternative set of heading styles with chapter numbers in the Page Number Format dialog, which only lists the built-in heading styles in the dropdown. (Actually displaying this list in the dialog isn’t necessary – we just want the same result). Is there a way to effectively replace the built-in styles with the alternative set using VBA?

IOW, instead of ‘Chapter starts with style: Heading 1’, we want to be able to specify ‘Chapter starts with style: Appendix 1’ for that part of the document.

enter image description here

The documentation for the PageNumbers object says you have to apply a list template before you can include chapter numbers, so it sounds like there should be a way to do this, but I wasn’t able to figure it out from the example code.

1

There are 1 best solutions below

0
Gabrielle On

Thanks to Timothy Rylatt for letting me know what I wanted to do isn't possible, and that I needed to use the built-in Heading styles. I've revised my Appendices list style so that the first three levels point to Heading styles 7-9, changing their formats to what had been my Appendix 1-3 styles. (I kept the remaining Appendix styles for the remainder of the list style, since they don't need to appear in the TofC.) That works if I add a custom TofC, based on style, that shows Headings 7-9 at levels 1-3.

The only problem with using Headings 7-9 styles as appendices is that the Navigation pane shows them indented at Levels 7-9, and that can be disorienting, especially if more than the first 3 appendix levels are used. But I don't suppose there's a way around that.

I also needed to indicate to users that Heading 7-9 styles were for appendices. I tried changing the name of the styles, but Word added the original style name to my name (e.g., 'Heading 7, Heading 7 (Appendix Level 1)'). Does anyone know if changing the names, to say, 'Heading 7, (Appendix 1)' for example, causes any problems with any built-in features?