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 / Mailmerge and Fax / November 2006

Tip: Looking for answers? Try searching our database.

custom record selection for mailmerge

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Klaus - 19 Nov 2006 21:21 GMT
Here is my problem.
I am creating cards (4 up per page). On the front side i want to print some
information from a word database in the sequence of row 1: record 1, 2  row
2: record  3, 4. However on the back (second run through the printer), I want
to print some more info from the database, but now the record sequence is row
1: record 2, 1 row 2: record 4, 3 and so on.
So now i have to create a formula to print the data in this new sequence.
Any ideas??
Doug Robbins - Word MVP - 20 Nov 2006 04:07 GMT
The following code was put together for someone who wanted to compile a
document by taking alternate pages from separate files.  If you were to
execute two separate mail merges to individual documents, you could use this
code to then combine them into one and then duplex print them to get what
you want.

   Dim sourcea As Document, sourceb As Document, target As Document, Pages
As Integer, Counter As Integer, targetrange As Range 'targetrange added

   Dim evenpage As Range

   Set sourcea = Documents.Open(FileName:="...")

   sourcea.Repaginate

   Pages = ActiveDocument.BuiltInDocumentProperties(wdPropertyPages)

   MsgBox Pages

   Set sourceb = Documents.Open(FileName:="...")

   Set target = Documents.Add

   target.PageSetup.LeftMargin = sourcea.PageSetup.LeftMargin

   target.PageSetup.RightMargin = sourcea.PageSetup.RightMargin

   target.PageSetup.TopMargin = sourcea.PageSetup.TopMargin

   target.PageSetup.BottomMargin = sourcea.PageSetup.BottomMargin

   target.AcceptAllRevisions

   Counter = 0

   While Counter < Pages

       sourcea.Activate

       ActiveDocument.Bookmarks("\page").Range.Copy

       Set targetrange = target.Range

       targetrange.Start = targetrange.End

       targetrange.Paste

       ActiveDocument.Bookmarks("\page").Range.Cut

       sourceb.Activate 'Assumed to be the document containing the even
pages

       Selection.EndKey Unit:=wdStory 'Line of code added to start from the
end of the document

       ActiveDocument.Bookmarks("\page").Range.Copy

       Set targetrange = target.Range

       targetrange.Start = targetrange.End

       targetrange.Paste

       targetrange.Start = targetrange.End

       targetrange.InsertBreak Type:=wdPageBreak

       Set evenpage = ActiveDocument.Bookmarks("\page").Range

       evenpage.Start = evenpage.Start - 1

       evenpage.Delete

       Counter = Counter + 1

   Wend

   sourcea.Close wdDoNotSaveChanges

   sourceb.Close wdDoNotSaveChanges

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

> Here is my problem.
> I am creating cards (4 up per page). On the front side i want to print
[quoted text clipped - 8 lines]
> So now i have to create a formula to print the data in this new sequence.
> Any ideas??
 
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.