Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / April 2005

Tip: Looking for answers? Try searching our database.

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

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
John C Brainard - 28 Apr 2005 15:02 GMT
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
Doug Robbins - 28 Apr 2005 16:25 GMT
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

Signature

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

>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
[quoted text clipped - 25 lines]
>    Selection.Find.Execute
>    Selection.Find.Execute Replace:=wdReplaceAl
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.