#1
|
|||
|
|||
merge two documents alternatively
I have two 604 page documents. Lets say we call them document A and B.
I want to weave/merge them alternatively to create one single output that look like this: A1, B1, A2, B2, A3, B3, ....., A604, B604 Any leads please? |
#2
|
|||
|
|||
Uhm....
How do you define A1, B1, etc. How is word going to know what you want? Before you answer that, please read: Word Doesn't Know What a Page Is |
#3
|
|||
|
|||
Thank you for your reply.
Like the following macro, I want to do the same thing that he wanted to achieve: Merge - Weave two documents odd and even pages - Microsoft Community But there are errors in the above macro and it doesn't work. I easily converted both documents to pdf files and merged them alternatively. Still wondering if it could be done in word alone. |
#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? |
#5
|
|||
|
|||
Yes I did. I also read the final paragraph that says:
Many of the limitations mentioned here can be overcome with the help of macros written in VBA. And that's exactly why I sent that piece of macro. |
#6
|
|||
|
|||
I have tremendous faith in the author of that code. Doug's experience, knowledge and skill exceeds my own.
Would you care to share two documents where the code does not work? How to attach a file in this forum. |
#7
|
|||
|
|||
Thank you for the reply.
Due to copyright issues unfortunately I can't share the documents. Though even the script gave me the same error with the following documents. |
#8
|
|||
|
|||
gets stuck at this line:
targetrange.Paste says the command is not available. |
#9
|
|||
|
|||
Te code ran straight through with your samples for me. I ended up with some extra blank pages and had to fiddle with them but it worked.
|
#10
|
|||
|
|||
Thank you.
So then I tested it on another computer with Windows 7 and office 2016. It worked and it didn't give any errors!! very strange! The code has created nearly 600 extra blank pages. I think I have to sort it out in draft view! |
Tags |
merge |
Thread Tools | |
Display Modes | |
|
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 |