Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 04-29-2014, 07:58 PM
TechEd TechEd is offline I need to select the first instance of a specific para style Windows XP I need to select the first instance of a specific para style Office 2010 32bit
Novice
I need to select the first instance of a specific para style
 
Join Date: May 2011
Posts: 16
TechEd is on a distinguished road
Default 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.
Reply With Quote
  #2  
Old 04-29-2014, 09:59 PM
macropod's Avatar
macropod macropod is offline I need to select the first instance of a specific para style Windows 7 32bit I need to select the first instance of a specific para style Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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]
Reply With Quote
  #3  
Old 04-29-2014, 11:22 PM
TechEd TechEd is offline I need to select the first instance of a specific para style Windows XP I need to select the first instance of a specific para style Office 2010 32bit
Novice
I need to select the first instance of a specific para style
 
Join Date: May 2011
Posts: 16
TechEd is on a distinguished road
Default

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...
Reply With Quote
  #4  
Old 04-29-2014, 11:56 PM
macropod's Avatar
macropod macropod is offline I need to select the first instance of a specific para style Windows 7 32bit I need to select the first instance of a specific para style Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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]
Reply With Quote
  #5  
Old 04-30-2014, 12:19 AM
TechEd TechEd is offline I need to select the first instance of a specific para style Windows XP I need to select the first instance of a specific para style Office 2010 32bit
Novice
I need to select the first instance of a specific para style
 
Join Date: May 2011
Posts: 16
TechEd is on a distinguished road
Default

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...
Reply With Quote
  #6  
Old 04-30-2014, 12:26 AM
macropod's Avatar
macropod macropod is offline I need to select the first instance of a specific para style Windows 7 32bit I need to select the first instance of a specific para style Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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]
Reply With Quote
Reply



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
I need to select the first instance of a specific para style 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

Other Forums: Access Forums

All times are GMT -7. The time now is 03:55 AM.


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