How Can I Write to the Comments Field of a Document?

How Can I Write to the Comments Field of a Document?

  • Comments 6
  • Likes
Hey, Scripting Guy! Question

Hey, Scripting Guy! Can I add text to the Comments field of a file using a script?

-- EF

SpacerHey, Scripting Guy! AnswerScript Center

Hey, EF. For those of you who aren’t sure what EF is referring to, right-click a document in Windows Explorer and then click Properties. In the dialog box that appears, click on the Summary tab. See the text box labeled Comments? That’s the field EF would like to be able to populate using a script.

So is that possible? As a matter of fact it is, provided you go to the Downloads Center on and download Dsofile. Dsofile installs a new COM object that allows you to both read from and write to the summary information fields for a document. For example, here’s a script that adds the clever comment “This is a comment” to the Comments field for a document:

Set objPropertyReader = CreateObject("DSOleFile.PropertyReader")
Set objDocument = objPropertyReader.GetDocumentProperties _
objDocument.Comments = "This is a comment."

Pretty slick, huh? Summary information fields you can change using a script include: Author; Category; Comments; Company; Keywords; LastEditedBy; Manager; Subject; and Title.

And, of course, you can read the summary information fields as well:

Set objPropertyReader = CreateObject("DSOleFile.PropertyReader")
Set objDocument = objPropertyReader.GetDocumentProperties _
Wscript.Echo "App name: " & objDocument.AppName
Wscript.Echo "Author: " & objDocument.Author
Wscript.Echo "Byte count: " & objDocument.ByteCount
Wscript.Echo "Category: " & objDocument.Category
Wscript.Echo "Character count: " & objDocument.CharacterCount
Wscript.Echo "Character count with spaces: " & objDocument.CharacterCountWithSpaces
Wscript.Echo "CLSID: " & objDocument.CLSID
Wscript.Echo "Comments: " & objDocument.Comments
Wscript.Echo "Company: " & objDocument.Company
Set colCustomProperties = objDocument.CustomProperties
For Each strProperty in colCustomProperties
    Wscript.Echo vbTab & strProperty.Name & ": " & strProperty.Value
Wscript.Echo "Date created: " & objDocument.DateCreated
Wscript.Echo "Date last printed: " & objDocument.DateLastPrinted
Wscript.Echo "Date last saved: " & objDocument.DateLastSaved
Wscript.Echo "Has macros: " & objDocument.HasMacros
Wscript.Echo "Hidden slides: " & objDocument.HiddenSlides
Wscript.Echo "Icon: " & objDocument.Icon
Wscript.Echo "Is read only: " & objDocument.IsReadOnly
Wscript.Echo "Keywords" & objDocument.Keywords
Wscript.Echo "Last edited by: " & objDocument.LastEditedBy
Wscript.Echo "Line count: " & objDocument.LineCount
Wscript.Echo "Location: " & objDocument.Location
Wscript.Echo "Manager: " & objDocument.Manager
Wscript.Echo "Multimedia clips: " & objDocument.MultimediaClips
Wscript.Echo "Name: " & objDocument.Name
Wscript.Echo "Page count: " & objDocument.PageCount
Wscript.Echo "Paragraph count: " & objDocument.ParagraphCount
Wscript.Echo "Presentation format: " & objDocument.PresentationFormat
Wscript.Echo "Presentation notes: " & objDocument.PresentationNotes
Wscript.Echo "ProgID: " & objDocument.ProgID
Wscript.Echo "Revision number: " & objDocument.RevisionNumber
Wscript.Echo "Slide count: " & objDocument.SlideCount
Wscript.Echo "Subject: " & objDocument.Subject
Wscript.Echo "Template: " & objDocument.Template
Wscript.Echo "Thumbnail: " & objDocument.Thumbnail
Wscript.Echo "Title: " & objDocument.Title
Wscript.Echo "Version: " & objDocument.Version
Wscript.Echo "Word count: " & objDocument.WordCount

Before you ask, we don’t know of any method built into the operating system that enables you to modify the summary information fields; you’ll have to download Dsofile to do that. It is possible, however, to read at least some of this information using the Windows Shell object. For details, check out this section of the Microsoft Windows 2000 Scripting Guide.

Your comment has been posted.   Close
Thank you, your comment requires moderation so it may take a while to appear.   Close
Leave a Comment
  • Much like anything you endeavor to understand there is a learning method integrated into a certification system.

  • The company you choose is crucial when you are searching for professional SEO benefits that assurance certified action and extended company.

  • Even if your look for motor engine positioning is good but the keyword and key phrase choice was poor, it would be spend of money for you because your company would not be any better than it was earlier (before the SEO process started).

  • You can reach to an viewers of your own choice according to your business requirements, and strategies, through this search engine optimization strategy.

  • Airplanes do NOT violate the laws of gravity. They do not "work around" anything. You need to brush up on Newton's Laws.

  • We offer a truly cost-effective SEO support for only $129 monthly and shift you up online ranking positions each 30 days or you don't pay. We even business 100 % free SEO in come returning for percentage on web revenue with certain companies. Just contact to see if you are eligible.