#1
|
|||
|
|||
I need to select the first instance of a specific para style
I am working on a document that has front matter, a main body of content, and a number of appendices. I have used Word's hierarchical numbering system to create the headings with (Heading 6) used to create the appendix level 1s. I need to select the first instance of a heading 6 so that I can use its page number to manipulate the overall page numbering. The overall document numbering is formatted as 'Page n of nn' with the front matter in Roman numerals, the main body in Arabic numerals, and no numbering in the appendix section. I need (1) to work out the number of the last page before the appendices and (2) to stop the numbering being inserted into the footers of the appendices section. I think I can do (1) and (2) if I could select Appendix A. PS I'm an absolute newbie at VBA so apologies beforehand if this is so simple you're all surprised I had to ask. |
#2
|
||||
|
||||
To see how to create a document with front matter & different numbering arrangements, see:
http://word.mvps.org/faqs/formatting...atter_2007.htm None of this requires VBA and you can use Find/Replace to find the first paragraph in the 'Heading 6' Style. Depending on how many Sections your document has, you might find creating the 'Y' part of the 'Page X of Y' numbering the greatest challenge.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#3
|
|||
|
|||
Hi Paul,
First, thanks for our rapid response - The document I am working on is a template where the page numbering is defined and updated from the ribbon (I have added a tab and relevant button). The original solution worked well because the numbering was reasonably simple to construct. The front matter was roman letters (e.g. Page i of vii) and the body and appendices were arabic numbers (e.g. Page 4 of 45) where page 45 was at the end of the document and included the appendices. The page number of the split was easy to determine because the first Heading 1 had a fixed title "Executive Summary" and so was easy to select. However, the "powers that be" have now decided that the appendices should not be numbered and the numbering should end on the last page before the appendices start. This means I need to determine the page number of the first appendix and use that (minus 1) to determine the total number of pages in the main body. (Hope that makes sense and is not too obtuse.) Hold everything I might have a solution: If I place the cursor at the start of the doc and then use Find to locate a heading 6 it must go to the first instance (of heading 6 in the doc). I will let you know if that works... |
#4
|
||||
|
||||
If you have a template, there is no need to have buttons on the ribbon to define the page numbering. All of that should be defined in the template itself. From your description, the template needs three Sections, each delimited by a "Next Page" Section break:
1. Front matter; page #s formatted as Roman Numerals, in X of Y format. 2. Body; page #s formatted as Arabic, in X of Y format 3. Appendices; no page #s. Configured that way, the 'Y' expressions for both numbered Sections can be calculated via SECTIONPAGES field.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#5
|
|||
|
|||
Hi Paul
It would be nice if the end users would restrict themselves to the three sections and that is certainly the way I would choose to do the numbering. However, the template is for engineering reports where the main body could be up to three hundred pages or more and is usually liberally splashed with section breaks - engineers just love section breaks: pages are often added in landscape and A3 pages added into the A4 normal pages (so you can see my predicament). The solution in the previous post just worked (as usual, it was a lot simpler than I thought) so thank you for your help. PS Just for interest, this page numbering procedure is part of a much larger "update all" automated procedure that updates the TOC and Tables of Figures and Tables; headers and footers; custom fields, etc... |
#6
|
||||
|
||||
In that case, you can still control the page numbering for the body fairly easily, starting with a template that has the layout described in my previous post. What you can do is:
1. In the first section (front matter) header, insert a field coded as: {SET Front {SECTIONPAGES \* Arabic}} 2. In the last section (appendices) header, insert a field coded as: {SET Back {SECTIONPAGES \* Arabic}} 3. For the body numbering, use a field coded as follows for the 'Y' part of the 'Page X of Y' numbering: {={NUMPAGES}-Front-Back \# 0} That way, regardless of how many Section breaks the body has, its body will always have the correct 'Page X of Y' numbering. Note: The field brace pairs (i.e. '{ }') for the above examples are all created in the document itself, via Ctrl-F9 (Cmd-F9 on a Mac); you can't simply type them or copy & paste them from this message. Nor is it practicable to add them via any of the standard Word dialogues.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Find instance of a word in a specific style and change its color | hwg | Word VBA | 7 | 02-20-2014 10:59 PM |
Select specific pages to print or save | Jack Byrindi | Word VBA | 0 | 01-16-2014 03:14 PM |
How to set style automatically for specific texts | ragesz | Word | 2 | 07-25-2013 07:08 AM |
Macro to replace one specific heading style with another | ubns | Word VBA | 44 | 09-04-2012 08:17 PM |
Don't add space between para of the same style | ghumdinger | Word | 3 | 09-19-2011 02:04 AM |