Page break befor headline

patrik
NewLounger
Posts: 3
Joined: 11 Apr 2022, 08:50

Page break befor headline

Post by patrik »

Hello

I have much unformated docs.
There are some headlines that should have an page break befor.

In the sample, I would have an page break befor "1.1.1.1.2 Mittelwerte für vereinbarte Partikelgrößen" , "1.2.1.1.2 Mittelwerte für vereinbarte Partikelgrößen" ( not in the sample ) and so on.

An format with the headline-format, would not work, because of more headlines with diffent names should not have an page break.

How can I achieve that?

Thanks for your help.
You do not have the required permissions to view the files attached to this post.

User avatar
StuartR
Administrator
Posts: 12601
Joined: 16 Jan 2010, 15:49
Location: London, Europe

Re: Page break befor headline

Post by StuartR »

I would do this by creating two different styles. Headline and Headline-pagebreak
StuartR


patrik
NewLounger
Posts: 3
Joined: 11 Apr 2022, 08:50

Re: Page break befor headline

Post by patrik »

How can I define the Headline-pagebreak-style to every "Mittelwerte" Headline? Clicking on each is not the solution I am searching for.
There are 5 - 15 in every doc and about 30 doc.

Thanks

User avatar
HansV
Administrator
Posts: 78393
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Page break befor headline

Post by HansV »

Welcome to Eileen's Lounge!

You could run this macro:

Code: Select all

Sub AddPageBreaks()
    Selection.HomeKey Unit:=wdStory
    With Selection.Find
        .Text = "Mittelwerte für vereinbarte Partikelgrößen"
        .ClearFormatting
        .Style = wdStyleHeading5
        .Wrap = wdFindStop
        Do While .Execute
            Selection.ParagraphFormat.PageBreakBefore = True
        Loop
    End With
End Sub
Best wishes,
Hans

patrik
NewLounger
Posts: 3
Joined: 11 Apr 2022, 08:50

Re: Page break befor headline

Post by patrik »

Thanks HansV
That what I was looking for and helps me so much.