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

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

  • Comments 5
  • 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.

  • With the help of a SEO Queensland organization, you will be able to get your website a lot more strikes very easily.

  • Such promotions are going to be very much valuable and secure to utilize since the technique will be created after comprehensive research to press out the SEO potential that have proven mixture of low maintenance SEO solutions. Inexpensive may also mean that they strategies create use of computerized application.

  • An abbreviation for seo, SEO is often a practice implemented by most online promoters to enhance the exposure of the website. If the SEO process was applied efficiently, web visitors to the website will certainly enhance. This in turn will truly boost the sale of products or solutions offered by the company.