Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / September 2006

Tip: Looking for answers? Try searching our database.

replace manual page breaks

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
tjtjjtjt - 08 Sep 2006 19:19 GMT
Is it possible to programmatically replace all manual page breaks in a
document with Next Page Section Breaks?
Thanks.
Signature

tj

Jean-Guy Marcil - 08 Sep 2006 19:57 GMT
tjtjjtjt was telling us:
tjtjjtjt nous racontait que :

> Is it possible to programmatically replace all manual page breaks in a
> document with Next Page Section Breaks?
> Thanks.

Try:

With ActiveDocument.Range.Find
   .ClearFormatting
   .Text = "^m"
   Do While .Execute
       With .Parent
           .Delete
           .InsertBreak wdSectionBreakNextPage
       End With
   Loop
End With

But watch out! Adding section breaks can mess up your headers/footers/page
numbering/etc..

Signature

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org

Helmut Weber - 08 Sep 2006 21:11 GMT
Hi Jean-Guy,

i'm ashamed, i was on the completely wrong track,
being so obsessed with section breaks.

Signature

Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"

Jean-Guy Marcil - 09 Sep 2006 00:14 GMT
Helmut Weber was telling us:
Helmut Weber nous racontait que :

> Hi Jean-Guy,
>
> i'm ashamed, i was on the completely wrong track,
> being so obsessed with section breaks.

LOL

Not really, no need to be ashamed, you were just doing some lateral
thinking!

Signature

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org

tjtjjtjt - 09 Sep 2006 17:13 GMT
Thanks. That does it!

Actually, I'm want the Section Breaks to preapre the document for Headers
and Footers (which I didn't originally plan to use...and wouldn't if it was
up to me). I was a bit distressed to find that there was no option to use the
Replace feature to switch Page Breaks for Section Breaks.

Now, I'm going to (hopefully) use this code as part of a bigger routine that
will take the first paragraph of Heading 2 text in each section and make that
part of the Header, along with page numbering that starts at one for each
Section.

tj

> tjtjjtjt was telling us:
> tjtjjtjt nous racontait que :
[quoted text clipped - 18 lines]
> But watch out! Adding section breaks can mess up your headers/footers/page
> numbering/etc..
Russ - 09 Sep 2006 18:12 GMT
Tjtjjtjt,

> Thanks. That does it!
>
[quoted text clipped - 6 lines]
> will take the first paragraph of Heading 2 text in each section and make that
> part of the Header,

You know how dictionaries can show the first and last definition on a page
header?

Check out this information on styleref fields used in headers in Word:
http://tinyurl.com/kcn4x

> along with page numbering that starts at one for each
> Section.
[quoted text clipped - 23 lines]
>> But watch out! Adding section breaks can mess up your headers/footers/page
>> numbering/etc..

Signature

Russ

drsmN0SPAMikleAThotmailD0Tcom.INVALID

Tony Jollans - 09 Sep 2006 20:22 GMT
> I was a bit distressed to find that there was no option to use the
> Replace feature to switch Page Breaks for Section Breaks.

You can do it using F&R ...

Add a section break to your document, select it and copy it, delete it, and
then Replace All ^m with ^c.

The disadvantage - which may not affect you very much - is that it copies in
section formatting from the section you first created rather than inheriting
from where the break is.

> will take the first paragraph of Heading 2 text in each section and make that
> part of the Header

Take a look at StyleRef Fields for this

> along with page numbering that starts at one for each
> Section.

Having replaced Page Breaks with Section Breaks are you  not going to have a
lot of Page 1s?

--
Enjoy,
Tony
tjtjjtjt - 10 Sep 2006 00:51 GMT
Word 2003 does not seem to let me select a Section Break and Copy it into the
Replace with box. If I try with the keyboard, it only selects the Paragraph
mark on the same line with the Section Break and/or any text on that line.
Perhaps I'm missing a step, but I don't see what that could be.

Using ^c in the Replace with box puts ^c in the document instead of a
Section Break.

Signature

tj

> > I was a bit distressed to find that there was no option to use the
> > Replace feature to switch Page Breaks for Section Breaks.
[quoted text clipped - 23 lines]
> Enjoy,
> Tony
Tony Jollans - 10 Sep 2006 06:07 GMT
Perhaps I should have been more explicit. Copy the section break but do not
paste it anywhere; ^c uses the contents of the clipboard for the
replacement.

--
Enjoy,
Tony

> Word 2003 does not seem to let me select a Section Break and Copy it into the
> Replace with box. If I try with the keyboard, it only selects the Paragraph
[quoted text clipped - 34 lines]
> > Enjoy,
> > Tony
Helmut Weber - 08 Sep 2006 20:05 GMT
Hi,

>Is it possible to programmatically replace all manual page breaks in a
>document with Next Page Section Breaks?

programmatically there are no manual page breaks.
There are breaks of certain types:
'wdSectionContinuous ' 0
'wdSectionNewColumn ' 1
'wdSectionNewPage ' 2
'wdSectionEvenPage ' 3
'wdSectionOddPage '4

Maybe you can adapt the following,
otherwise ask again.

Sub test012()
Dim rDcm As Range ' the documents range
Set rDcm = ActiveDocument.Range
With rDcm.Find
  .Text = Chr(12)
  While .Execute
  rDcm.Select ' for testing using [F8]
  MsgBox KindofBreak12(rDcm)
  ' rDcm.Collapse Direction:=wdCollapseEnd
  ' might be necessary together with replace
  Wend
End With
End Sub

Public Function KindofBreak12(ByVal rTmp As Range) As String
Dim lSct1 As Long  ' counter for sections
Dim lSct2 As Long  ' counter for sections
Dim lKoSc As Long  ' kind of section.pagesetup.sectionstart
rTmp.start = ActiveDocument.Range.start
lSct1 = rTmp.Sections.Count ' count sections
rTmp.End = rTmp.End + 1     ' extend range
lSct2 = rTmp.Sections.Count ' count sections again
If lSct1 = lSct2 Then       ' next caracter is in the same section
  KindofBreak12 = "ordinary page break"
  Exit Function
End If
' next character is in the next section
lKoSc = ActiveDocument.Sections(lSct2).PageSetup.SectionStart
Select Case lKoSc
  Case 0:  KindofBreak12 = "wdSectionContinuous"
  Case 2:  KindofBreak12 = "wdSectionNewPage"
  Case 3:  KindofBreak12 = "wdSectionEvenPage"
  Case 4:  KindofBreak12 = "wdSectionOddPage"
End Select
End Function

see in addition:

http://tinyurl.com/hkrxd

Signature

Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.