Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #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,584
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
 

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 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 09:24 PM.


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