#1
|
|||
|
|||
Making all lines following page breaks a particular style
Hi there - I have a word Doc that is virtually unformatted. It's just under 700 pages...
However it DOES contain a good number of page breaks (approx 500). I'd like to essentially take the first line after each page break and turn it into a heading, so I can then compile a table of contents based on those "first lines after page breaks". I feel this should be achievable quite easily, but I'm having a mental blank on how. Any pointers / suggestions gratefully received. Thanks in advance. |
#2
|
||||
|
||||
Without seeing the document, the following should do that. It searches for manual page breaks and adds the built-in Title paragraph style to the line following the page break. You can format that style however you wish:
Code:
Sub Macro1() Dim orng As Range Set orng = ActiveDocument.Range orng.Paragraphs(1).Range.Style = "Title" With orng.Find Do While .Execute(findText:="^m") orng.Collapse 0 orng.Next.Paragraphs(1).Style = "Title" Loop End With End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
#3
|
|||
|
|||
An improvement might be to add Page-break-before formatting to your Title or Heading 1 style and delete the manual page breaks.
|
#4
|
|||
|
|||
"Heading 1" would be more appropriate.
The default Style of "Title" will not be included in the Table of Contents and would have to be modified for it to. Charles Kenyon's suggestion to add the Page breaking before the Heading Style is a good recommendation. @ eludlow I am not a fan of using Manual Page Breaks until working on the Layout of a document. The case in which you have used demonstrates the negatives and doesn't take advantage of Styles. I would also recommend beginning your document creation by using the Outline View and DO NOT WORRY about formatting till later. Your text formatting should all be done using Styles. This is a huge concern when dealing with large documents when text formatting should be consistent. Example, you wouldn't want long quotes to be formatted different in different sections of a long document. Direct Formatting is convenient, but a horrible opportunity for inconsistencies and problematic updating/changing. Last edited by Charles Kenyon; 01-15-2022 at 06:13 PM. Reason: typo |
#5
|
|||
|
|||
For more support for spillerbd's suggestions, see:
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Two-line heading in TOC is making two lines of dot leaders | betsyg | Word | 4 | 06-13-2019 02:18 PM |
Avoid continous breaks turn into page breaks | sponge | Word | 3 | 09-14-2017 12:11 PM |
Hidden page breaks and section breaks | jrasicmark | Word | 3 | 06-02-2014 11:28 PM |
Keep with Next/Keep Lines Together (to adjust page breaks) | lewiskm55 | Word | 1 | 05-02-2011 08:18 AM |
Deleted Section Breaks Changes Page Breaks | Brantnshellie | Word | 0 | 02-01-2009 09:22 PM |