-
Try this. Click "Page Break" on top toolbar. You are using - UGH! - 2007 so I do not know if this will show correctly for you. It is NOT a 2007 file. In case it does not, here is the code:[vba]
Sub PageB()
Dim oPara As Paragraph
Dim r As Range
For Each oPara In ActiveDocument.Paragraphs
If InStr(1, oPara.Range.Text, "Page#") > 0 Then
Set r = ActiveDocument.Range( _
Start:=oPara.Range.Start, _
End:=oPara.Range.Start)
r.InsertBreak Type:=wdPageBreak
End If
Next
For Each oPara In ActiveDocument.Paragraphs
If oPara.Range.Text = vbCr Then
oPara.Range.Delete
End If
Next
' delete first break if at start
Set oPara = ActiveDocument.Paragraphs(1)
If Left(oPara.Range.Text, 1) = Chr(12) Then
oPara.Range.Text = _
Right(oPara.Range.Text, Len(oPara.Range.Text) - 1)
End If
End Sub
[/vba]What it does is look for paragraphs with "Page#", inserting a page break before that paragraph. It then looks for those "empty" paragraphs, and deletes them. It then check to see if the document starts with a page break (it does now), and removes THAT page break.
Your paragraphs of:
___________________________________________________________________________ _____________________
that are NOT before a Page# are retained.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules