{"id":71313,"date":"2004-10-01T11:18:00","date_gmt":"2004-10-01T11:18:00","guid":{"rendered":"https:\/\/blogs.technet.microsoft.com\/heyscriptingguy\/2004\/10\/01\/how-can-i-write-to-the-comments-field-of-a-document\/"},"modified":"2004-10-01T11:18:00","modified_gmt":"2004-10-01T11:18:00","slug":"how-can-i-write-to-the-comments-field-of-a-document","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/scripting\/how-can-i-write-to-the-comments-field-of-a-document\/","title":{"rendered":"How Can I Write to the Comments Field of a Document?"},"content":{"rendered":"<p><IMG class=\"nearGraphic\" title=\"Hey, Scripting Guy! Question\" border=\"0\" alt=\"Hey, Scripting Guy! Question\" align=\"left\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/q-for-powertip.jpg\" width=\"34\" height=\"34\"> \n<P>Hey, Scripting Guy! Can I add text to the Comments field of a file using a script?<BR><BR>&#8212; EF<\/P><IMG border=\"0\" alt=\"Spacer\" src=\"https:\/\/devblogs.microsoft.com\/scripting\/wp-content\/uploads\/sites\/29\/2019\/05\/spacer.gif\" width=\"5\" height=\"5\"><IMG class=\"nearGraphic\" title=\"Hey, Scripting Guy! Answer\" border=\"0\" alt=\"Hey, Scripting Guy! Answer\" align=\"left\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/a-for-powertip.jpg\" width=\"34\" height=\"34\"><A href=\"http:\/\/go.microsoft.com\/fwlink\/?linkid=68779&amp;clcid=0x409\"><IMG class=\"farGraphic\" title=\"Script Center\" border=\"0\" alt=\"Script Center\" align=\"right\" src=\"http:\/\/img.microsoft.com\/library\/media\/1033\/technet\/images\/scriptcenter\/ad.jpg\" width=\"120\" height=\"288\"><\/A> \n<P>Hey, EF. For those of you who aren\u2019t sure what EF is referring to, right-click a document in Windows Explorer and then click <B>Properties<\/B>. In the dialog box that appears, click on the <B>Summary<\/B> tab. See the text box labeled <B>Comments<\/B>? That\u2019s the field EF would like to be able to populate using a script.<\/P>\n<P>So is that possible? As a matter of fact it is, provided you go to the <A href=\"http:\/\/null\/downloads\/search.aspx?displaylang=en\"><B>Downloads Center on Microsoft.com<\/B><\/A> 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\u2019s a script that adds the clever comment \u201cThis is a comment\u201d to the Comments field for a document:<\/P><PRE class=\"codeSample\">Set objPropertyReader = CreateObject(&#8220;DSOleFile.PropertyReader&#8221;)\nSet objDocument = objPropertyReader.GetDocumentProperties _\n    (&#8220;C:\\Scripts\\Test.doc&#8221;)\nobjDocument.Comments = &#8220;This is a comment.&#8221;\n<\/PRE>\n<P>Pretty slick, huh? Summary information fields you can change using a script include: Author; Category; Comments; Company; Keywords; LastEditedBy; Manager; Subject; and Title.<\/P>\n<P>And, of course, you can read the summary information fields as well:<\/P><PRE class=\"codeSample\">Set objPropertyReader = CreateObject(&#8220;DSOleFile.PropertyReader&#8221;)\nSet objDocument = objPropertyReader.GetDocumentProperties _\n    (&#8220;C:\\Scripts\\Test.doc&#8221;)\nWscript.Echo &#8220;App name: &#8221; &amp; objDocument.AppName\nWscript.Echo &#8220;Author: &#8221; &amp; objDocument.Author\nWscript.Echo &#8220;Byte count: &#8221; &amp; objDocument.ByteCount\nWscript.Echo &#8220;Category: &#8221; &amp; objDocument.Category\nWscript.Echo &#8220;Character count: &#8221; &amp; objDocument.CharacterCount\nWscript.Echo &#8220;Character count with spaces: &#8221; &amp; objDocument.CharacterCountWithSpaces\nWscript.Echo &#8220;CLSID: &#8221; &amp; objDocument.CLSID\nWscript.Echo &#8220;Comments: &#8221; &amp; objDocument.Comments\nWscript.Echo &#8220;Company: &#8221; &amp; objDocument.Company\nSet colCustomProperties = objDocument.CustomProperties\nFor Each strProperty in colCustomProperties\n    Wscript.Echo vbTab &amp; strProperty.Name &amp; &#8220;: &#8221; &amp; strProperty.Value\nNext\nWscript.Echo &#8220;Date created: &#8221; &amp; objDocument.DateCreated\nWscript.Echo &#8220;Date last printed: &#8221; &amp; objDocument.DateLastPrinted\nWscript.Echo &#8220;Date last saved: &#8221; &amp; objDocument.DateLastSaved\nWscript.Echo &#8220;Has macros: &#8221; &amp; objDocument.HasMacros\nWscript.Echo &#8220;Hidden slides: &#8221; &amp; objDocument.HiddenSlides\nWscript.Echo &#8220;Icon: &#8221; &amp; objDocument.Icon\nWscript.Echo &#8220;Is read only: &#8221; &amp; objDocument.IsReadOnly\nWscript.Echo &#8220;Keywords&#8221; &amp; objDocument.Keywords\nWscript.Echo &#8220;Last edited by: &#8221; &amp; objDocument.LastEditedBy\nWscript.Echo &#8220;Line count: &#8221; &amp; objDocument.LineCount\nWscript.Echo &#8220;Location: &#8221; &amp; objDocument.Location\nWscript.Echo &#8220;Manager: &#8221; &amp; objDocument.Manager\nWscript.Echo &#8220;Multimedia clips: &#8221; &amp; objDocument.MultimediaClips\nWscript.Echo &#8220;Name: &#8221; &amp; objDocument.Name\nWscript.Echo &#8220;Page count: &#8221; &amp; objDocument.PageCount\nWscript.Echo &#8220;Paragraph count: &#8221; &amp; objDocument.ParagraphCount\nWscript.Echo &#8220;Presentation format: &#8221; &amp; objDocument.PresentationFormat\nWscript.Echo &#8220;Presentation notes: &#8221; &amp; objDocument.PresentationNotes\nWscript.Echo &#8220;ProgID: &#8221; &amp; objDocument.ProgID\nWscript.Echo &#8220;Revision number: &#8221; &amp; objDocument.RevisionNumber\nWscript.Echo &#8220;Slide count: &#8221; &amp; objDocument.SlideCount\nWscript.Echo &#8220;Subject: &#8221; &amp; objDocument.Subject\nWscript.Echo &#8220;Template: &#8221; &amp; objDocument.Template\nWscript.Echo &#8220;Thumbnail: &#8221; &amp; objDocument.Thumbnail\nWscript.Echo &#8220;Title: &#8221; &amp; objDocument.Title\nWscript.Echo &#8220;Version: &#8221; &amp; objDocument.Version\nWscript.Echo &#8220;Word count: &#8221; &amp; objDocument.WordCount\n<\/PRE>\n<P>Before you ask, we don\u2019t know of any method built into the operating system that enables you to modify the summary information fields; you\u2019ll have to download Dsofile to do that. It <I>is<\/I> possible, however, to read at least some of this information using the Windows Shell object. For details, check out this section of the <A href=\"http:\/\/null\/technet\/scriptcenter\/guide\/sas_fil_lunl.mspx\"><B>Microsoft Windows 2000 Scripting Guide<\/B><\/A>.<\/P><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hey, Scripting Guy! Can I add text to the Comments field of a file using a script?&#8212; EF Hey, EF. For those of you who aren\u2019t 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 [&hellip;]<\/p>\n","protected":false},"author":595,"featured_media":87096,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[38,3,12,5],"class_list":["post-71313","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-scripting","tag-files","tag-scripting-guy","tag-storage","tag-vbscript"],"acf":[],"blog_post_summary":"<p>Hey, Scripting Guy! Can I add text to the Comments field of a file using a script?&#8212; EF Hey, EF. For those of you who aren\u2019t 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 [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/71313","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/users\/595"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/comments?post=71313"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/71313\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media\/87096"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media?parent=71313"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/categories?post=71313"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/tags?post=71313"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}