Consulting

Results 1 to 2 of 2

Thread: Copying changed pages from one document to new one

  1. #1
    VBAX Regular
    Joined
    Aug 2016
    Posts
    10
    Location

    Exclamation Copying changed pages from one document to new one

    I have a document which has Track Changes turned on and contains a number of revisions. I am trying to create a script that will take the contents of a page that has a revision and copy it to a new document so that the new document will contain only those pages that have changed. Unfortunately, in the script I have written now, the code selects the first page for copying every time through the loop. Here is the code I have so far:
    For Each oRevision In oDoc.Revisions
            oDoc.Activate
            revNum = revNum + 1
            'If this page hasn't already been copied (for multiple revisions on single page)
            If oRevision.Range.Information(wdActiveEndPageNumber) <> nLastPageNum Then
                'Also check that the change is not in the header or footer
                If oRevision.Range.StoryType = wdMainTextStory Then
                    MsgBox (oRevision.Range.Text)
                    'Add 1 to counter
                    n = n + 1
                    ActiveDocument.Bookmarks("\Page").Select
                    Selection.Copy
                    oNewDoc.Activate
                    Selection.EndKey wdStory
                    Selection.InsertBreak (wdPageBreak)
                    Selection.PasteAndFormat wdPasteDefault
                    nLastPageNum = oRevision.Range.Information(wdActiveEndPageNumber)
                End If
            End If
        Next oRevision
    I'm sure the 2nd part (pasting) is working fine, but the first portion where I select the page keeps selecting the first page rather than the page that has the change. Any help would be greatly appreciated.

    Chris

  2. #2
    Knowledge Base Approver VBAX Guru macropod's Avatar
    Joined
    Jul 2008
    Posts
    4,435
    Location
    Cross-posted (and answered) at: http://www.msofficeforums.com/word-v...s-changes.html
    Please read VBA Express' policy on Cross-Posting in item 3 of the rules: http://www.vbaexpress.com/forum/faq...._new_faq_item3
    Cheers
    Paul Edstein
    [Fmr MS MVP - Word]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •