#1
|
|||
|
|||
Use StyleRef based on previous page - IF this-and-that
Hello,
My apologies in advance for being yet another noob who abuses this forum for his own problems... I really have practically no knowledge of Visual Basic or the "Fields" of Word. But I do have a project in which they (hopefully) offer the grail to my quest. Here are the variables of what I want to achieve:
Do you see any possibility to make this magic happen? Thanks in advance for your help! |
#2
|
|||
|
|||
Take a look at Useful StyleRef tricks by Suzanne Barnhill, MVP. It should give you a start with using the StyleRef Field. The StyleRef field is one of the underutilized tools provided by Word.
I would recommend getting rid of all of the \* MERGEFORMAT switches. I know of no way of ignoring a target style on the same page as the header when it is not in the first line. You might want to start using Page Break Before formatting for that style so it will always be the first line of a page. |
#3
|
|||
|
|||
Quote:
Unless that first line is in itself a heading 1 or 2 (which means the first line of "real" text belongs to the chapter of said heading). Actually there are a couple of things I would want to combine. For that to work, they must of course be possible on their own...
|
#4
|
|||
|
|||
Impossible?
|
#5
|
|||
|
|||
Did you look at Suzanne's page?
Be patient. This is a user-to-user support forum with no connection to Microsoft. Others may weigh in. |
#6
|
|||
|
|||
Hey RAFCRIK,
I came upon this thread also looking for an answer to this kind of problem, and in the mean-time have happened upon a solution. I know it's been a while since you asked, but if it's not helpful for you hopefully it will be to somebody else. Background: In my document's header, I am using {styleref} fields to print '{Heading 1}: {Heading 2}'. I also wanted this to display heading information for the text at the top of the page, but this was problematic for me because the heading text was generally on the previous page. Fortunately, the style of my document was similar to that which Charles had suggested above, and for the 'Heading 1' style, each was preceded by a page break. The trouble I had was specifically with 'Heading 2'. On each page where there is no new text in the 'Heading 1' or 'Heading 2' styles, Word will search back up the document (like we want it to!), finding the previous instance and referencing that. For me, this meant the field {Heading 1} was always correct, but {Heading 2} was incorrect, unless it happened to begin at the top of the page. Solution: Immediately before every new 'Heading 2' style, I added a {Heading 2} field, and then applied the 'Heading 2' style to it. Word searches the current page (importantly: above the field) for the 'Heading 2' style. Because it doesn't appear on this page yet (remember: this is before the next 'Heading 2' instance), Word keeps searching up to the previous page, finding the last instance of 'Heading 2' on the previous page (or, presumably, earlier? This was not an issue for me as I have level two headings on every page, just not always at the start of the page). Once the preceding heading is in place, you want to make it 'invisible'. Because you can't use the 'hidden' text feature, I simply changed the font size to 1, and font colour to white. To keep consistency in formatting, I have inserted this tiny white text above all of my headings that aren't at the top of the next page (this ensures there's not a spacing difference). Hope this helps! Examples: Imagine the text at the top of my page belongs to a heading called 'Heading 1.1' So at the top of my page I want it to show that. Below that text, Heading 1.2 begins, however, so the header is instead referencing that text. At the beginning, my page initially looks like this... ------- top of page ------- HEADING 1.2 {‘Heading 1’} ------ end of header ------ amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. HEADING 1.2 Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. ------- end of page ------- Note: The {} after text indicate that text has been called by the field. After step one, my page now looks like this... ------- top of page ------- HEADING 1.1 {‘Heading 1’} ------ end of header ------ amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. HEADING 1.1 {‘Heading 1’} HEADING 1.2 Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. ------- end of page ------- After step two, my page now looks like this... (On a white background, you can't see the heading text) ------- top of page ------- HEADING 1.1 {‘Heading 1’} ------ end of header ------ amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. HEADING 1.1 {‘Heading 1’} HEADING 1.2 Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. ------- end of page ------- |
#7
|
|||
|
|||
Amenoire - More Info Please
@amenoire, your example is exactly what I was looking for! But I don't understand the "Heading 2 Field" you mention. I don't see a word field of type "Heading 2"; do you mean a "ref" field to the heading 2? Or perhaps a cross-reference?
Immediately before every new 'Heading 2' style, I added a {Heading 2} field... |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Auto fill based on previous entry | geojf3 | Word VBA | 6 | 11-25-2019 06:49 AM |
Start page numbering on second page ("link to previous" is greyed-out) | seanspotatobusiness | Word | 1 | 07-11-2018 10:33 AM |
Table on top of page breaks the paragraph on previous page | iffee82 | Word Tables | 18 | 05-10-2018 02:44 AM |
Table adding cells to previous page with room still on current page. | gedet | Word | 1 | 01-03-2018 10:35 AM |
MS Word, page goes to next page when entering data on previous page | munna94 | Word | 2 | 12-30-2010 08:12 AM |