#1
|
|||
|
|||
Insert manual page breaks
I have a third part reporting application that creates reports in docx format but doesn't insert pages breaks. I create a template in docx format and it replaces certain sections with graphs, etc. but I need to be able to add page breaks in sections that are part of a loop so the final report could have two, three, four, etc. page breaks. For example:
[Loop=floors] This is floor <floorname> <show floorplan> [Somehow instruct Word to insert a page break here] [Loop Repeat] Is there anyway I can create an "instruction" to tell Word to insert a manual page break? |
#2
|
||||
|
||||
If there is some consistent text (or even a text pattern), for example, that precedes and/or follows everywhere there should be a page break, you could co it via Find/Replace.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#3
|
|||
|
|||
At the moment I have inserted the text "---Break---" into the template and I am doing a find/replace but I was hopeful of finding a more elegant solution.
|
#4
|
||||
|
||||
You could run the replacement from a macro via a button on the ribbon, which you may consider more elegant? See http://www.gmayor.com/installing_macro.htm
Code:
Sub AddPageBreaks() Const strFind As String = "---Break---" Dim oRng As Range Set oRng = ActiveDocument.Range With oRng.Find Do While .Execute(strFind) oRng.Text = "" oRng.InsertBreak wdPageBreak oRng.Collapse 0 Loop End With lbl_Exit: Set oRng = Nothing Exit Sub End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
#5
|
||||
|
||||
Why are you inserting "---Break---" into the template? Why not insert the page break instead? Moreover, as I've already said, even that can be done via Find/Replace (or a macro using Find/Replace) if there is some consistent text (or even a text pattern), for example, that precedes and/or follows everywhere there should be a page break. Since you haven't provided any detail about that, at this stage we can only speculate.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#6
|
|||
|
|||
Is "This is floor <floorname>" always going to be at the top of a new page? If so, how about defining a style for that paragraph, and make one of the style's attributes (under "paragraph") be "Page break before"?
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Hidden page breaks and section breaks | jrasicmark | Word | 3 | 06-02-2014 11:28 PM |
Remove Manual Line Breaks not working | dvdb | Word | 2 | 03-28-2014 12:51 PM |
Insert section breaks in a protected document | MS help | Word | 2 | 03-09-2014 05:27 PM |
Page breaks and page numbering | sfteam | Word | 3 | 06-06-2013 11:56 PM |
Deleted Section Breaks Changes Page Breaks | Brantnshellie | Word | 0 | 02-01-2009 09:22 PM |