![]() |
|
#4
|
|||
|
|||
|
I know I sound pedantic, but please tell us how Word is to tell what is to go in each document.
Did you read the page I linked previously? For others reading, this is the code that you say is not doing what you want: Code:
Dim sourcea As Document, sourceb As Document, target As Document, Pages As Integer, Counter As Integer, targetrange As Range
Dim evenpage As Range
Set sourcea = Documents.Open(FileName:="...") 'Document containing the odd pages
Set sourceb = Documents.Open(FileName:="...") 'Document containing the even pages
sourceb.Repaginate
Pages = sourceb.BuiltInDocumentProperties(wdPropertyPages)
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
Selection.HomeKey wdStory
ActiveDocument.Bookmarks("\page").Range.Copy
Set targetrange = target.Range
targetrange.Collapse wdCollapseEnd
targetrange.Paste
sourcea.Bookmarks("\page").Range.Cut
sourceb.Activate
Selection.HomeKey wdStory
ActiveDocument.Bookmarks("\page").Range.Copy
Set targetrange = target.Range
targetrange.Collapse wdCollapseEnd
targetrange.Paste
targetrange.Start = targetrange.End
targetrange.InsertBreak Type:=wdPageBreak
sourceb.Bookmarks("\page").Range.Cut
Counter = Counter + 1
Wend
sourcea.Range.Copy
Set targetrange = target.Range
targetrange.Collapse wdCollapseEnd
targetrange.Paste
sourcea.Close wdDoNotSaveChanges
sourceb.Close wdDoNotSaveChanges
Perhaps you can tell us what you get that is different from what you want? |
| Tags |
| merge |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| 100 Primary Mail Merge Documents - want to add a table with fields to all of the primary documents | revans611 | Mail Merge | 3 | 09-15-2020 12:07 PM |
Merge documents
|
coriolisss | Word VBA | 3 | 11-16-2018 03:14 PM |
| How to merge track changes from 2 documents | jbz | Word | 1 | 09-18-2015 01:30 PM |
Merge to Seperate Documents
|
joughin | Mail Merge | 1 | 05-17-2012 05:08 PM |
Merge documents
|
ilce | Mail Merge | 1 | 02-16-2012 02:33 PM |