{"id":52603,"date":"2009-08-27T03:01:00","date_gmt":"2009-08-27T03:01:00","guid":{"rendered":"https:\/\/blogs.technet.microsoft.com\/heyscriptingguy\/2009\/08\/27\/hey-scripting-guy-how-can-i-figure-out-which-version-of-microsoft-office-word-is-on-a-bunch-of-computers\/"},"modified":"2009-08-27T03:01:00","modified_gmt":"2009-08-27T03:01:00","slug":"hey-scripting-guy-how-can-i-figure-out-which-version-of-microsoft-office-word-is-on-a-bunch-of-computers","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/scripting\/hey-scripting-guy-how-can-i-figure-out-which-version-of-microsoft-office-word-is-on-a-bunch-of-computers\/","title":{"rendered":"Hey, Scripting Guy! How Can I Figure Out Which Version of Microsoft Office Word Is on a Bunch of Computers?"},"content":{"rendered":"<p class=\"MsoNormal\">&nbsp;<\/p>\n<p class=\"MsoNormal\"><img decoding=\"async\" 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\"><\/p>\n<p class=\"MsoNormal\">Hey Scripting Guy! We are currently beta testing Microsoft Office 2010. It is awesome by the way, and I need to figure out what version of Word we have installed on our computers. I know there are different versions, and I would like to get some kind of inventory before we do the upgrade. How can I determine the version of Word that is installed on our computers?<\/p>\n<\/p>\n<p class=\"MsoNormal\">&#8212; CC<\/p>\n<p class=\"MsoNormal\">\n<p><span><img decoding=\"async\" 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\"><\/span><\/p>\n<\/p>\n<p class=\"MsoNormal\">Hello CC, <\/p>\n<p class=\"MsoNormal\">Microsoft Scripting Guy Ed Wilson here. One of the cool things about Facebook is the way we can keep up to date with our friends, co-workers, and <a href=\"http:\/\/www.facebook.com\/group.php?gid=5901799452\">fans of the Hey Scripting Guy! articles<\/a>. This morning, for example, I found out that my buddy Pete in Australia just finished his certification as a cave diver. For those of you who might not know, cave diving is awesome, but can also be potentially dangerous if done incorrectly. This is why it is important to have advanced training before attempting to go spelunking underwater. The potential for silting (fine dirt on the bottom that gets mixed up with the water turning it into soup) to reduce visibility to zero can make finding your way out of the cave nearly impossible unless you have a line to follow. <\/p>\n<p class=\"MsoNormal\">CC, trying to write scripts is certainly not as dangerous as cave diving, but it can certainly be as confusing as a silted cave. Luckily, you have a line that you can follow&mdash;our new <a href=\"http:\/\/gallery.technet.microsoft.com\/ScriptCenter\/en-us\">Script Center Script Gallery<\/a>. I did a search on our Script Gallery and found a really cool script that displays the version of Word. It is a VBScript; however, we can use it as a line to follow to lead us to a nice Windows PowerShell script. The DetermineTheVersionOfMicrosoftWordInstalledOnAComputer.vbs VBScript is seen here. <span>&nbsp;<\/span><\/p>\n<p class=\"CodeBlockScreenedHead\"><strong>DetermineTheVersionOfMicrosoftWordInstalledOnAComputer.vbs<\/p>\n<p><\/strong><\/p>\n<p class=\"CodeBlockScreened\"><span><font><font face=\"Lucida Sans Typewriter\">Set objWord = CreateObject(&#8220;Word.Application&#8221;)<\/p>\n<p><\/font><\/font><\/span><\/p>\n<p class=\"CodeBlockScreened\"><span><font><font face=\"Lucida Sans Typewriter\">Wscript.Echo &#8220;Version: &#8221; &amp; objWord.Version<\/p>\n<p><\/font><\/font><\/span><\/p>\n<p class=\"CodeBlockScreened\"><span><font><font face=\"Lucida Sans Typewriter\">Wscript.Echo &#8220;Build: &#8221; &amp; objWord.Build<\/p>\n<p><\/font><\/font><\/span><\/p>\n<p class=\"CodeBlockScreened\"><span><font><font face=\"Lucida Sans Typewriter\">Wscript.Echo &#8220;Product Code: &#8221; &amp; _<\/p>\n<p><\/font><\/font><\/span><\/p>\n<p class=\"CodeBlockScreened\"><span><font><font face=\"Lucida Sans Typewriter\"><span>&nbsp;&nbsp;&nbsp; <\/span>objWord.ProductCode()<\/p>\n<p><\/font><\/font><\/span><\/p>\n<p class=\"CodeBlockScreened\"><span><font><font face=\"Lucida Sans Typewriter\">objWord.Quit<\/p>\n<p><\/font><\/font><\/span><\/p>\n<p class=\"MsoNormal\">The first thing the DetermineTheVersionOfMicrosoftWordInstalledOnAComputer.vbs script does is create an instance of the <a href=\"http:\/\/blogs.technet.com\/heyscriptingguy\/archive\/tags\/Word.Application\/default.aspx\"><font face=\"Segoe\">Word.Application<\/font><\/a> object. <span>&nbsp;<\/span>In VBScript you used the <b>CreateObject<\/b> command to create a COM object. In Windows PowerShell, you use the <b>New-Object<\/b> cmdlet to create a new object. If the object you want to create is a COM object, you use the <b>comobject<\/b> parameter. You do not need to use quotation marks when specifying the program ID of the COM object. This is seen here: <\/p>\n<p class=\"CodeBlock\"><span><font face=\"Lucida Sans Typewriter\">$objword = new-object -comobject word.application<\/p>\n<p><\/font><\/span><\/p>\n<p class=\"MsoNormal\">VBScript required you to use <b>Wscript.Echo<\/b> or some other command to produce output from the script. Because Windows PowerShell was designed as a console application, it does not require anything special to display information in the Windows PowerShell console. If you put something in quotation marks, it will automatically be displayed in the Windows PowerShell console. To concatenate (glue stuff together), you use the plus sign (<b>+<\/b>). The version of Microsoft Word is a property of the <b>Word.Application<\/b> object. <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/bb225979.aspx\"><font face=\"Segoe\">MSDN documents many methods and properties<\/font><\/a> from the <b>Word.Application<\/b> object. To display the version, you print a string that states it is the version and use the concatenation operator to display the Word version. This is seen here: <\/p>\n<p class=\"CodeBlock\"><span><font face=\"Lucida Sans Typewriter\">&#8220;version: &#8221; + $objword.version<\/p>\n<p><\/font><\/span><\/p>\n<p class=\"MsoNormal\">You use exactly the same process to display the build number of Word:<\/p>\n<p class=\"CodeBlock\"><span><font face=\"Lucida Sans Typewriter\">&#8220;build: &#8221; + $objword.build<\/p>\n<p><\/font><\/span><\/p>\n<p class=\"MsoNormal\">To get the product code of Microsoft Word, you have to use a method. This is documented in MSDN&#8217;s description of the <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/bb209102.aspx\"><font face=\"Segoe\">ProductCode method<\/font><\/a>. When calling a method in Windows PowerShell, you must place parentheses at the end of the method name. This is seen here: <\/p>\n<p class=\"CodeBlock\"><span><font face=\"Lucida Sans Typewriter\">&#8220;productcode: &#8221; + $objword.productcode()<\/p>\n<p><\/font><\/span><\/p>\n<p class=\"MsoNormal\">The last thing you must do is call the <b>quit<\/b> method from the <strong>Word.Application<\/strong> object. If you do not, you will end up with several instances of WINWORD.EXE running on your computer, as seen here:<\/p>\n<p class=\"Fig-Graphic\"><img decoding=\"async\" title=\"Image of more than one instance of WINWORD.EXE running at the same time\" alt=\"Image of more than one instance of WINWORD.EXE running at the same time\" src=\"http:\/\/img.microsoft.com\/library\/media\/1033\/technet\/images\/scriptcenter\/qanda\/hsg\/2009\/august\/hey0827\/hsg-8-27-09-01.jpg\" width=\"600\" height=\"405\"><\/p>\n<p class=\"MsoNormal\"><br>The <b>quit<\/b> method is defined on the Application object and will accept <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/bb215475.aspx\"><font face=\"Segoe\">three optional parameters<\/font><\/a>. You do not need to save any changes, specify the formatting, or route the document to the next recipient. You can call the method with no parameters, and it will simply exit the application and release the object from memory. This is seen here: <\/p>\n<p class=\"CodeBlock\"><span><font face=\"Lucida Sans Typewriter\">$objword.quit()<\/p>\n<p><\/font><\/span><\/p>\n<p class=\"MsoNormal\">The completed DetermineTheVersionOfMicrosoftWordInstalledOnAComputer.ps1 script is seen here. <\/p>\n<p class=\"CodeBlockScreenedHead\"><strong>DetermineTheVersionOfMicrosoftWordInstalledOnAComputer.ps1<\/p>\n<p><\/strong><\/p>\n<p class=\"CodeBlock\"><span><font face=\"Lucida Sans Typewriter\">$objword = new-object -comobject word.application<\/p>\n<p><\/font><\/span><\/p>\n<p class=\"CodeBlock\"><span><font face=\"Lucida Sans Typewriter\">&#8220;version: &#8221; + $objword.version<\/p>\n<p><\/font><\/span><\/p>\n<p class=\"CodeBlock\"><span><font face=\"Lucida Sans Typewriter\">&#8220;build: &#8221; + $objword.build<\/p>\n<p><\/font><\/span><\/p>\n<p class=\"CodeBlock\"><span><font face=\"Lucida Sans Typewriter\">&#8220;productcode: &#8221; + $objword.productcode()<\/p>\n<p><\/font><\/span><\/p>\n<p class=\"CodeBlock\"><span><font face=\"Lucida Sans Typewriter\">$objword.quit()<\/p>\n<p><\/font><\/span><\/p>\n<p class=\"MsoNormal\">When the script runs, the following output is displayed.<\/p>\n<p class=\"Fig-Graphic\"><img decoding=\"async\" title=\"Image of the output of the script\" alt=\"Image of the output of the script\" src=\"http:\/\/img.microsoft.com\/library\/media\/1033\/technet\/images\/scriptcenter\/qanda\/hsg\/2009\/august\/hey0827\/hsg-8-27-09-02.jpg\" width=\"600\" height=\"157\"><\/p>\n<p class=\"MsoNormal\"><br>It might be a bit more useful to check if a specific version of Word is installed on a computer. To do this, you can easily turn the script into a function. To turn the script into a function, you use the <b>function<\/b> keyword, and give the function a name, such as <b>Get-WordVersion<\/b>. Inside the code block (the curly brackets), you copy the code from the previous script. You do not want to return anything but the Word version number, so the function only retrieves the Word version property. The function will automatically return the value to the calling code. This is seen here: <\/p>\n<p class=\"CodeBlock\"><span><font face=\"Lucida Sans Typewriter\">Function Get-WordVersion<\/p>\n<p><\/font><\/span><\/p>\n<p class=\"CodeBlock\"><span><font face=\"Lucida Sans Typewriter\">{<\/p>\n<p><\/font><\/span><\/p>\n<p class=\"CodeBlock\"><span><font face=\"Lucida Sans Typewriter\"><span>&nbsp;<\/span>$objword = new-object -comobject word.application<\/p>\n<p><\/font><\/span><\/p>\n<p class=\"CodeBlock\"><span><font face=\"Lucida Sans Typewriter\"><span>&nbsp;<\/span>$objword.version<\/p>\n<p><\/font><\/span><\/p>\n<p class=\"CodeBlock\"><span><font face=\"Lucida Sans Typewriter\"><span>&nbsp;<\/span>$objword.quit()<\/p>\n<p><\/font><\/span><\/p>\n<p class=\"CodeBlock\"><span><font face=\"Lucida Sans Typewriter\">} #end Get-WordVersion<\/p>\n<p><\/font><\/span><\/p>\n<p class=\"MsoNormal\">To call the function and to evaluate the Word version, you can use the <b>if<\/b> statement. This is seen here: <\/p>\n<p class=\"CodeBlock\"><span><font face=\"Lucida Sans Typewriter\">If(Get-WordVersion -eq 12) { &#8220;Word 12 found&#8221; } else { &#8220;Word 12 not found&#8221; }<\/p>\n<p><\/font><\/span><\/p>\n<p class=\"MsoNormal\">The complete DetermineTheVersionOfMicrosoftWordInstalledOnAComputerFunction.ps1 script is seen here. <\/p>\n<p class=\"CodeBlockScreenedHead\"><strong>DetermineTheVersionOfMicrosoftWordInstalledOnAComputerFunction.ps1<\/p>\n<p><\/strong><\/p>\n<p class=\"CodeBlock\"><span><font face=\"Lucida Sans Typewriter\">Function Get-WordVersion<\/p>\n<p><\/font><\/span><\/p>\n<p class=\"CodeBlock\"><span><font face=\"Lucida Sans Typewriter\">{<\/p>\n<p><\/font><\/span><\/p>\n<p class=\"CodeBlock\"><span><font face=\"Lucida Sans Typewriter\"><span>&nbsp;<\/span>$objword = new-object -comobject word.application<\/p>\n<p><\/font><\/span><\/p>\n<p class=\"CodeBlock\"><span><font face=\"Lucida Sans Typewriter\"><span>&nbsp;<\/span>$objword.version<\/p>\n<p><\/font><\/span><\/p>\n<p class=\"CodeBlock\"><span><font face=\"Lucida Sans Typewriter\"><span>&nbsp;<\/span>$objword.quit()<\/p>\n<p><\/font><\/span><\/p>\n<p class=\"CodeBlock\"><span><font face=\"Lucida Sans Typewriter\">} #end Get-WordVersion<\/p>\n<p><\/font><\/span><\/p>\n<p class=\"CodeBlock\"><span><\/p>\n<p><font face=\"Lucida Sans Typewriter\">&nbsp;<\/font><\/p>\n<p><\/span><\/p>\n<p class=\"CodeBlock\"><span><font face=\"Lucida Sans Typewriter\"># *** Entry Point to Script ***<\/p>\n<p><\/font><\/span><\/p>\n<p class=\"CodeBlock\"><span><\/p>\n<p><font face=\"Lucida Sans Typewriter\">&nbsp;<\/font><\/p>\n<p><\/span><\/p>\n<p class=\"CodeBlock\"><span><font face=\"Lucida Sans Typewriter\">If(Get-WordVersion -eq 12) { &#8220;Word 12 found&#8221; } else { &#8220;Word 12 not found&#8221; }<\/p>\n<p><\/font><\/span><\/p>\n<p class=\"MsoNormal\">When the DetermineTheVersionOfMicrosoftWordInstalledOnAComputerFunction.ps1 script runs, the following output is displayed.<\/p>\n<p class=\"Fig-Graphic\"><img decoding=\"async\" title=\"Image of the output of the script\" alt=\"Image of the output of the script\" src=\"http:\/\/img.microsoft.com\/library\/media\/1033\/technet\/images\/scriptcenter\/qanda\/hsg\/2009\/august\/hey0827\/hsg-8-27-09-03.jpg\" width=\"600\" height=\"125\"><a href=\"http:\/\/img.microsoft.com\/library\/media\/1033\/technet\/images\/scriptcenter\/qanda\/hsg\/2009\/august\/hey0827\/hsg-8-27-09-03.jpg\"><span><font face=\"Segoe\"><\/font><\/span><\/a><br><\/p>\n<p class=\"MsoNormal\">CC, that is all there is to determining the version of Microsoft Word that is installed on your computer. This also ends our week of perusing the new <a href=\"http:\/\/gallery.technet.microsoft.com\/ScriptCenter\/en-us\">Script Gallery<\/a>. <\/p>\n<p class=\"MsoNormal\">Join us tomorrow as we dive into the virtual mail bag and come up with an assortment of questions that do not require long answers. That&rsquo;s right! It&rsquo;s the return of Quick-Hits Friday. If you want to keep up to date on activities on the Script Center follow us on <a href=\"https:\/\/twitter.com\/scriptingguys\/\">Twitter<\/a> or on <a href=\"http:\/\/www.facebook.com\/group.php?gid=5901799452\">Facebook<\/a>. If you have questions, you can post them on the <a href=\"http:\/\/social.technet.microsoft.com\/Forums\/en\/ITCG\/threads\/\"><span><font face=\"Segoe\">Official Scripting Guys Forum<\/font><\/span><\/a>, or send them by e-mail to <a href=\"http:\/\/blogs.technet.commailto:scripter@microsoft.com\"><span><font face=\"Segoe\">scripter@microsoft.com<\/font><\/span><\/a>. Until tomorrow, have a great day!<\/p>\n<p><b><span><br>Ed Wilson and Craig Liebendorfer, Scripting Guys<\/p>\n<p><\/span><\/b><\/p>\n<p><b><span><\/p>\n<p>&nbsp;<\/p>\n<p><\/span><\/b><\/p>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp; Hey Scripting Guy! We are currently beta testing Microsoft Office 2010. It is awesome by the way, and I need to figure out what version of Word we have installed on our computers. I know there are different versions, and I would like to get some kind of inventory before we do the upgrade. [&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":[84,49,3,45,395],"class_list":["post-52603","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-scripting","tag-microsoft-word","tag-office","tag-scripting-guy","tag-windows-powershell","tag-word-application"],"acf":[],"blog_post_summary":"<p>&nbsp; Hey Scripting Guy! We are currently beta testing Microsoft Office 2010. It is awesome by the way, and I need to figure out what version of Word we have installed on our computers. I know there are different versions, and I would like to get some kind of inventory before we do the upgrade. [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/52603","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=52603"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/52603\/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=52603"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/categories?post=52603"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/tags?post=52603"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}