1. No Profile Picture
    Registered User
    ASP Explorer (0 - 99 posts)

    Join Date
    Feb 2007
    Rep Power

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

    Hi Guys,

    I have tried the Script given by Scripting Guy! (Microsoft Site) 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:\work\Document1.doc")

    Set colComments = objWord1.Comments

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


    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.
  2. #2
  3. ASP Hero (2000 - 2499 posts)

    Join Date
    Jun 2006
    New Springfield, OH
    Rep Power
    The Microsoft Word object doesn't have a Collection property so your colComments collection is empty.

    This code is bad:
    vb Code:
    Set colComments = objWord1.Comments
    For Each objComment in colComments
    strComments = strComments & objComment.Text & vbCrlf & vbCrLf

    This type of code is often much more trouble than it's worth, but if you're still intent on trying it, take a closer look at the Selection property. There are tons of methods that go along with it too.

    Here's the Word object reference.

    And here's some good examples.
    Don't like me? Click it.

    Scripting problems? Windows questions? Ask the Windows Guru!

    Stay up to date with all of my latest content. Follow me on Twitter!

    Help us help you! Post your exact error message with these easy tips!!

Similar Threads

  1. Creating a word document based on a stored OLE (word) object
    By LordLona in forum Microsoft Access Help
    Replies: 0
    Last Post: August 30th, 2005, 03:07 PM
  2. Copy bookmarks to new document
    By christylynn in forum Visual Basic Programming
    Replies: 0
    Last Post: November 10th, 2004, 01:50 PM
  3. Need help using Access query data to fill a Microsoft Word document
    By passmaster16 in forum Microsoft Access Help
    Replies: 2
    Last Post: July 19th, 2004, 05:24 PM
  4. Emailing a Word document
    By jbarilow in forum ASP Development
    Replies: 1
    Last Post: April 14th, 2004, 02:38 PM
  5. Replies: 0
    Last Post: February 27th, 2004, 12:53 AM

IMN logo majestic logo threadwatch logo seochat tools logo