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

Re: replace manual page breaks by Helmut

Helmut
Fri Sep 08 14:05:21 CDT 2006

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

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

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


Re: replace manual page breaks by Jean-Guy

Jean-Guy
Fri Sep 08 13:57:48 CDT 2006

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..

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



Re: replace manual page breaks by Helmut

Helmut
Fri Sep 08 15:11:07 CDT 2006

Hi Jean-Guy,

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

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

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




Re: replace manual page breaks by Jean-Guy

Jean-Guy
Fri Sep 08 18:14:44 CDT 2006

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!

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



Re: replace manual page breaks by tjtjjtjt

tjtjjtjt
Sat Sep 09 11:13:02 CDT 2006

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


"Jean-Guy Marcil" wrote:

> 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..
>
> --
> Salut!
> _______________________________________
> Jean-Guy Marcil - Word MVP
> jmarcilREMOVE@CAPSsympatico.caTHISTOO
> Word MVP site: http://www.word.mvps.org
>
>
>

Re: replace manual page breaks by Russ

Russ
Sat Sep 09 12:12:39 CDT 2006

Tjtjjtjt,

> 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,

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.
>
> tj
>
>
> "Jean-Guy Marcil" wrote:
>
>> 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..
>>
>> --
>> Salut!
>> _______________________________________
>> Jean-Guy Marcil - Word MVP
>> jmarcilREMOVE@CAPSsympatico.caTHISTOO
>> Word MVP site: http://www.word.mvps.org
>>
>>
>>

--
Russ

drsmN0SPAMikleAThotmailD0Tcom.INVALID


Re: replace manual page breaks by Tony

Tony
Sat Sep 09 14:22:39 CDT 2006

> 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



Re: replace manual page breaks by tjtjjtjt

tjtjjtjt
Sat Sep 09 18:51:01 CDT 2006

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.


--
tj


"Tony Jollans" wrote:

> > 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
>
>
>

Re: replace manual page breaks by Tony

Tony
Sun Sep 10 00:07:40 CDT 2006

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

"tjtjjtjt" <tjtjjtjt@discussions.microsoft.com> wrote in message
news:788458C1-B346-4853-8A43-F9399B9241C7@microsoft.com...
> 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.
>
>
> --
> tj
>
>
> "Tony Jollans" wrote:
>
> > > 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
> >
> >
> >