View Single Post
 
Old 09-06-2020, 09:11 AM
Charles Kenyon Charles Kenyon is offline Windows 10 Office 2019
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 9,533
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