G
Guest
I am currently trying to write a macro to search for a particular style in a
Word document, and every time it is encountered insert a page break.
This seemed failry straightforwards. However, the problem I am having is
that the text contained in the Style is being replaced by the page break, so
I am getting page breaks without retaining the original paragraphs.
I obviously want to have both the page breaks and the paragraphs I have
searched for present.
Below is my code. Any suggestions much appreciated. I basically need a way
of making the Range the cursor input to the paragraph rather than the whole
paragraph itself and I am stuck as to how to do this.
Public Function InsertPageBreak()
Dim para As Word.Paragraph
For Each para In e3Doc.Paragraphs
If para.Style = "ScheduleTitle" Then
para.Range.InsertBreak Type:=wdPageBreak
End If
Next para
End Function
Any help very much appreciated. Adam
Word document, and every time it is encountered insert a page break.
This seemed failry straightforwards. However, the problem I am having is
that the text contained in the Style is being replaced by the page break, so
I am getting page breaks without retaining the original paragraphs.
I obviously want to have both the page breaks and the paragraphs I have
searched for present.
Below is my code. Any suggestions much appreciated. I basically need a way
of making the Range the cursor input to the paragraph rather than the whole
paragraph itself and I am stuck as to how to do this.
Public Function InsertPageBreak()
Dim para As Word.Paragraph
For Each para In e3Doc.Paragraphs
If para.Style = "ScheduleTitle" Then
para.Range.InsertBreak Type:=wdPageBreak
End If
Next para
End Function
Any help very much appreciated. Adam