Windows Scripting
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsSystem AdministrationWindows Scripting

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old February 13th, 2007, 01:23 AM
Praveer Praveer is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Feb 2007
Posts: 1 Praveer User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 m 46 sec
Reputation Power: 0
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")
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.

Reply With Quote
  #2  
Old February 14th, 2007, 01:28 AM
Nilpo's Avatar
Nilpo Nilpo is offline
ASP Free Beginner (1000 - 1499 posts)
 
Join Date: Jun 2006
Location: Salem, OH
Posts: 1,048 Nilpo User rank is Colonel (50000 - 60000 Reputation Level)Nilpo User rank is Colonel (50000 - 60000 Reputation Level)Nilpo User rank is Colonel (50000 - 60000 Reputation Level)Nilpo User rank is Colonel (50000 - 60000 Reputation Level)Nilpo User rank is Colonel (50000 - 60000 Reputation Level)Nilpo User rank is Colonel (50000 - 60000 Reputation Level)Nilpo User rank is Colonel (50000 - 60000 Reputation Level)Nilpo User rank is Colonel (50000 - 60000 Reputation Level)Nilpo User rank is Colonel (50000 - 60000 Reputation Level)Nilpo User rank is Colonel (50000 - 60000 Reputation Level)Nilpo User rank is Colonel (50000 - 60000 Reputation Level)Nilpo User rank is Colonel (50000 - 60000 Reputation Level)  Folding Points: 206875 Folding Title: Super Ultimate Folder - Level 1Folding Points: 206875 Folding Title: Super Ultimate Folder - Level 1Folding Points: 206875 Folding Title: Super Ultimate Folder - Level 1Folding Points: 206875 Folding Title: Super Ultimate Folder - Level 1Folding Points: 206875 Folding Title: Super Ultimate Folder - Level 1Folding Points: 206875 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 5 Days 12 h 32 m 33 sec
Reputation Power: 555
Send a message via ICQ to Nilpo Send a message via AIM to Nilpo Send a message via MSN to Nilpo Send a message via Yahoo to Nilpo Send a message via Google Talk to Nilpo Send a message via Skype to Nilpo
MySpace
The Microsoft Word object doesn't have a Collection property so your colComments collection is empty.

This code is bad:
vb Code:
Original - vb Code
  1. Set colComments = objWord1.Comments
  2.  
  3.  
  4. For Each objComment in colComments
  5. strComments = strComments & objComment.Text & vbCrlf & vbCrLf
  6. Next


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.
__________________
Click the image if at any point you don't like my decision.

Scripting problems? Windows questions? Ask the Windows Guru!


Reply With Quote
Reply

Viewing: ASP Free ForumsSystem AdministrationWindows Scripting > Can we Copy all Comments from a WORD document to another document ?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT