Can we Copy all Comments from a WORD document to another document

Discussion in 'Scripting' started by Praveer Verma, Feb 12, 2007.

  1. Hi Guys,

    I have tried the Script given by Scripting Guy! to copy comments from an
    Excel document to another WORD document. But I now wish to do same for WORD
    documents too. Thats is:
    I want to copy all comments of Word Document 1 to another document. this
    document will have only comments from Document 1.

    To do so I have set following script:
    Set objWord1 = CreateObject("Word.Application")
    objWord1.Visible = True

    Set objDoc1 = objWord1.Documents.Open("D:\Peoplesoft work\QA TestPlan
    PeopleSoft Adapter 8 1 1 (Reviewed-Harshal).doc")
    objDoc1.Activate

    Set colComments = objWord1.Comments


    For Each objComment in colComments
    strComments = strComments & objComment.Text & vbCrlf & vbCrLf
    Next

    objWord1.Quit

    Set objWord = CreateObject("Word.Application")
    objWord.Visible = True
    Set objDoc = objWord.Documents.Add()
    Set objSelection = objWord.Selection

    objSelection.TypeText strComments


    But I am getting following error:
    E:\Useful Scripts\Copy Comments (Word).vbs(7, 1) Microsoft VBScript runtime
    error: Object doesn't support this property or method: 'objWord1.Comments'

    Can any one help me here..

    Praveer Verma.
     
    Praveer Verma, Feb 12, 2007
    #1
    1. Advertisements

  2. Praveer Verma

    urkec Guest

    Set objWord = CreateObject("Word.Application")
    objWord.Visible = True

    Set objDoc1 = objWord.Documents.Open("C:\test.doc")
    objDoc1.Activate

    Set colComments = objDoc1.Comments

    For Each objComment in colComments
    strComments = strComments & objComment.Range.Text & vbCrlf & vbCrLf
    Next

    objDoc1.Close

    Set objDoc = objWord.Documents.Add()
    Set objSelection = objWord.Selection

    objSelection.TypeText strComments
     
    urkec, Feb 14, 2007
    #2
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.