Code for Insert Section Break, Please Look If you Know VBA

J

John C Brainard

I am trying to insert a section break before a certain piece of text. I
need to be able to print the first page of a bill to one tray, and the rest
to another tray. I have been told taht is accomplished by page/section
breaks in different points. Here is the code that i am having the problem
with:


I haven't been able to get it totally working. Here is the code i am using.
I can't seem to get the section break to work before i replace the data. the
line wiht the astrixes is the line giving me trouble

With Selection.Find
.Text = "
________________________________________________________________________________________________" & "^l" & " APR 1 - 2005 "
******* .Replacement.Text = Selection.InsertBreak & "^&"
.Forward = True
.Wrap = wdFindAsk
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.Find.Execute Replace:=wdReplaceAl
 
D

Doug Robbins

To insert a next page section break at the location of the cursor, use

Selection.InsertBreak wdSectionBreakNextPage

To insert a next page section break at the end of the first page of a
document, use

Selection.HomeKey wdStory
Selection.Bookmarks("\page").Range.Select
Selection.Collapse wdCollapseEnd
Selection.InsertBreak wdSectionBreakNextPage


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top