Adding blank page in word

sachin483

Board Regular
Joined
Mar 31, 2015
Messages
135
Office Version
  1. 2010
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

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().

Macropod

Retired Moderator
Joined
Aug 27, 2007
Messages
3,566
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?
 

Watch MrExcel Video

Forum statistics

Threads
1,132,816
Messages
5,655,462
Members
418,204
Latest member
ElizabethCorrin

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
Top