Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 09-05-2020, 04:20 PM
digiman digiman is offline merge two documents alternatively Windows 10 merge two documents alternatively Office 2019
Novice
merge two documents alternatively
 
Join Date: Sep 2020
Posts: 6
digiman is on a distinguished road
Default 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?
Reply With Quote
  #2  
Old 09-06-2020, 07:29 AM
Charles Kenyon Charles Kenyon is offline merge two documents alternatively Windows 10 merge two documents alternatively Office 2019
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 9,081
Charles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant future
Default

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
Reply With Quote
  #3  
Old 09-06-2020, 08:17 AM
digiman digiman is offline merge two documents alternatively Windows 10 merge two documents alternatively Office 2019
Novice
merge two documents alternatively
 
Join Date: Sep 2020
Posts: 6
digiman is on a distinguished road
Default

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.
Reply With Quote
  #4  
Old 09-06-2020, 09:11 AM
Charles Kenyon Charles Kenyon is offline merge two documents alternatively Windows 10 merge two documents alternatively Office 2019
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 9,081
Charles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant future
Default

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
It was posted in the Word Answers forum by MVP Doug Robbins.
Perhaps you can tell us what you get that is different from what you want?
Reply With Quote
  #5  
Old 09-08-2020, 11:58 PM
digiman digiman is offline merge two documents alternatively Windows 10 merge two documents alternatively Office 2019
Novice
merge two documents alternatively
 
Join Date: Sep 2020
Posts: 6
digiman is on a distinguished road
Default

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.
Reply With Quote
  #6  
Old 09-09-2020, 08:19 AM
Charles Kenyon Charles Kenyon is offline merge two documents alternatively Windows 10 merge two documents alternatively Office 2019
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 9,081
Charles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant future
Default

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.
Reply With Quote
  #7  
Old 09-09-2020, 08:31 AM
digiman digiman is offline merge two documents alternatively Windows 10 merge two documents alternatively Office 2019
Novice
merge two documents alternatively
 
Join Date: Sep 2020
Posts: 6
digiman is on a distinguished road
Default

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.
Attached Files
File Type: docx a.docx (11.6 KB, 6 views)
File Type: docx b.docx (11.6 KB, 5 views)
Reply With Quote
  #8  
Old 09-09-2020, 08:35 AM
digiman digiman is offline merge two documents alternatively Windows 10 merge two documents alternatively Office 2019
Novice
merge two documents alternatively
 
Join Date: Sep 2020
Posts: 6
digiman is on a distinguished road
Default

gets stuck at this line:

targetrange.Paste

says the command is not available.
Reply With Quote
  #9  
Old 09-09-2020, 11:34 AM
Charles Kenyon Charles Kenyon is offline merge two documents alternatively Windows 10 merge two documents alternatively Office 2019
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 9,081
Charles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant future
Default

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.
Reply With Quote
  #10  
Old 09-09-2020, 01:00 PM
digiman digiman is offline merge two documents alternatively Windows 10 merge two documents alternatively Office 2019
Novice
merge two documents alternatively
 
Join Date: Sep 2020
Posts: 6
digiman is on a distinguished road
Default

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!
Reply With Quote
Reply

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 two documents alternatively 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 two documents alternatively Merge to Seperate Documents joughin Mail Merge 1 05-17-2012 05:08 PM
merge two documents alternatively Merge documents ilce Mail Merge 1 02-16-2012 02:33 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 06:09 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft