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 2005

Tip: Looking for answers? Try searching our database.

Mail Merge End of File

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Frustrated Mail Merger - 02 Nov 2005 18:24 GMT
I am trying to do a mail merge into two separate tables in the same document.
However, when it gets done merging the first table it of course is at the
end of file.  Then when it gets to the second table in the document - it
doesn't merge anything because it's at the end of file.  How do I get it to
go back to the beginning of the file before it starts merging into the second
table?
Doug Robbins - Word MVP - 03 Nov 2005 06:33 GMT
Just how do you have the mergefields arranged in the mailmerge main
document?  The data should repeat for each instance of the mergefields in
the main document.

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 do a mail merge into two separate tables in the same
>document.
[quoted text clipped - 5 lines]
> second
> table?
Frustrated Mail Merger - 03 Nov 2005 14:29 GMT
The table on page 1 has 7 columns and many rows.  I have the fields placed in
the 1st row and then at the beginning of the 2nd row I have Next Record in
the first cell and then the fields placed like row 1.  The rest of the rows
are all like row 2 with Next Record in cell 1.  Then on page 5 of the same
document I have another table with different information - it has 11 columns
and many rows.  Again I have row 1 with the data I want placed and then on
the rest of the rows I have Next Record in cell 1 and the same data placed.  
The first table works fine - but it doesn't go back to the beginning of the
file for the table on page 5 (this table is blank).

> Just how do you have the mergefields arranged in the mailmerge main
> document?  The data should repeat for each instance of the mergefields in
[quoted text clipped - 9 lines]
> > second
> > table?
Doug Robbins - Word MVP - 03 Nov 2005 19:36 GMT
The only way to handle that will be to use two mailmerge maindocuments and
execute the merges to new documents and then to combine them back into one.
The following macro that was written for a person who wanted to create a
document made up by interleaving the pages from two separate documents,
could be modified to handle the combination of the two mail merge documents.

   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

> The table on page 1 has 7 columns and many rows.  I have the fields placed
> in
[quoted text clipped - 27 lines]
>> > second
>> > table?
 
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.