#1
|
|||
|
|||
page breaks Insertion
Hello,
Is there a way to insert pagebreaks to all pages using macro or word object model? I need this because we are see some soft page breaks missing when opened using OPENXML sdk. Regards Manohar |
#2
|
||||
|
||||
Inserting manual page breaks is certainly possible but doing so has adverse effects:
1. It splits paragraphs in two, which will cause an auto-numbered paragraph to become two sequentially-auto-numbered paragraphs. 2. It splits tables in two, which can be disastrous for tables using header rows to populate multiple pages - it also messes with cells that span page breaks. 3. It prevents Word from re-flowing the document content properly when opened on a computer using a different print driver to the one on which the page breaks were created. This can result on a new page being created with just one or two lines of text (containing as few as a single word) and/or other pages not being filled (having just a few words (if any) on the last available line for a paragraph that continues on the next page. I'm sure other contributors here can list more adverse effects, too - the above spring readily to mind. I'm not sure what you mean by "some soft page breaks missing" - soft page breaks, as such, don't exist in a Word document - they're nothing more than a display construct that shifts around while the document is open in response to edits.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#3
|
|||
|
|||
Chiming in to agree that manual page breaks make for documents that are extremely difficult to edit. What are you trying to accomplish with the page breaks?
|
#4
|
|||
|
|||
Our Goal is to convert a word document to some other format. We do this by the help of wordOpenXml property in the interop and openxml sdk. everything is working well so far but we have observed that some of the page breaks have been missed out in the wordOpenXml property output. for example : when the first paragraph is empty.
Can we mark the end of page or last character of a page with a bookmark or something, so that when we read that element from wordOpenXml we can consider it as a page break? if yes, how can we do it using macro. |
#5
|
||||
|
||||
All word-processors use a pagination approach analogous to Word's. Unless you're converting to a format used by a page layout program (e.g. one that produces PDFs - which Word can do on its own), there is nothing to be gained (and much to lose) by inserting such page breaks. Besides which, how do you propose to handle issues such as those I outlined?
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#6
|
|||
|
|||
We are converting to txt format. So we don't have to worry about other effects.
Can we mark the end of page or last character of a page with a bookmark or something, so that when we read that element from wordOpenXml we can consider it as a page break? if yes, how can we do it using macro. Thanks Manohar |
#7
|
||||
|
||||
Bookmarks won't survive conversion to text format. Your only option would be to insert a character or string that you can parse into a page break for wordOpenXml purposes. Indeed, if you know what the wordOpenXml code is for that, you might even be able to insert that code directly into the document.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#8
|
|||
|
|||
Thanks Paul, But how can we find the last character of the page?
|
#9
|
||||
|
||||
The following macro inserts prefixes every page with <pg> and ends it with </pg>
Code:
Sub Demo() Application.ScreenUpdating = False Dim i As Long With ActiveDocument For i = .ComputeStatistics(wdStatisticPages) To 2 Step -1 .GoTo(What:=wdGoToPage, Name:=i).InsertBefore "</pg><pg>" Next .Range.InsertBefore "<pg>" .Range.InsertAfter "</pg>" End With Application.ScreenUpdating = True End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Configured page size to 20 inches height : why the page still breaks @ the default 9,6” ? | Ron Wolpa | Word | 4 | 08-18-2016 06:43 PM |
Subdocuments without Page Breaks? | titani2 | Word | 8 | 08-26-2014 05:58 AM |
Hidden page breaks and section breaks | jrasicmark | Word | 3 | 06-02-2014 11:28 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 |