Copying changed pages to new document-VBForums
Results 1 to 2 of 2

Thread: Copying changed pages to new document

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 2017

    Exclamation Copying changed pages to new document

    I have a document which has Track Changes turned on and contains some revisions. I am trying to have the pages that contain revisions copied to a 2nd document so that the new doc will contain only the pages that have changed. The problem I'm having is that each time through the loop, the code is selecting the first page instead of the page with the change. Here is the code as it stands right now:
    For Each oRevision In oDoc.Revisions
            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
                    Selection.EndKey wdStory
                    Selection.InsertBreak (wdPageBreak)
                    Selection.PasteAndFormat wdPasteDefault
                    nLastPageNum = oRevision.Range.Information(wdActiveEndPageNumber)
                End If
            End If
        Next oRevision
    The message box is displaying the proper text, but when I get to the Select statement, it keeps selecting the first page instead. What am I doing wrong? Any help would be greatly appreciated.


  2. #2
    Frenzied Member
    Join Date
    Oct 2001
    Idaho Falls, Idaho USA

    Re: Copying changed pages to new document

    Not sure what the lines below are supposed to be doing:

    'Add 1 to counter
    n = n + 1

    However, the line below is probably selecting the same text every time:


    What you want is to select the text on the page with the revision range. You need the correct page number for that.

    Maybe something like:


    Possibly useful links:

Posting Permissions

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


Click Here to Expand Forum to Full Width