Adding blank page in word

sachin483

Board Regular
Joined
Mar 31, 2015
Messages
163
Office Version
  1. 2019
Platform
  1. Windows
i have to added blank page in word 2010 after every 3 , 6 , 9 , 12 till the end the below macro run but blank page is not inserted and the format should remain same

Code:
Sub PB()
    Selection.HomeKey Unit:=wdStory
    With Selection.Find
        .MatchWildcards = False
        .ClearFormatting
        .Text = "^p^p^p ^m"
        .Replacement.ClearFormatting
        .Replacement.Text = ""
        .Execute Replace:=wdReplaceAll
    End With
    Selection.HomeKey Unit:=wdStory
    With Selection.Find
        .MatchWildcards = True
        .Text = "(^13{3,}*^13{3,}*)^13{3,}"
        .Replacement.Text = "\1^m^m"
        .Wrap = wdFindStop
        .Execute Replace:=wdReplaceAll
    End With
End Sub
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
i have to added blank page in word 2010 after every 3 , 6 , 9 , 12 till the end
After "every 3 , 6 , 9 , 12" what? As it is, your code first deletes every set of 3 paragraph breaks followed by a space then a manual page break, before trying to find 3 or more paragraph breaks followed by anything at all until finding 3 or more paragraph breaks followed by anything at all until finding 3 or more paragraph breaks, replacing the last set of 3 or more paragraph breaks with two manual page breaks. What do you expect it to do? And what do you mean by "the format should remain same"? Same as what?
 
Upvote 0

Forum statistics

Threads
1,223,908
Messages
6,175,307
Members
452,633
Latest member
DougMo

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top