How Can I Determine Which Version of Word is Installed on a Computer?

How Can I Determine Which Version of Word is Installed on a Computer?

  • Comments 2
  • Likes
Hey, Scripting Guy! Question

Hey, Scripting Guy! How can I determine which version of Word is installed on a computer?

-- RR

SpacerHey, Scripting Guy! AnswerScript Center

Hey, RR. Turns out that this is a trickier question than you might expect. That’s because WMI does only a so-so job of retrieving information about the software installed on a computer. In theory, you can use a script like this one to get back version information for Microsoft Office:

strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

Set colApps = objWMIService.ExecQuery _
    ("Select * from Win32_Product Where Caption Like '%Microsoft Office%'")
For Each objApp in colApps
    Wscript.Echo objApp.Caption, objApp.Version
Next

So why not just use that script? Well, two reasons. First, this script uses the Like operator; that operator is available only on Windows XP and Windows 2003. (And, just to complicate things, the Win32_Product class is not installed by default on Windows 2003.) If you’re still running Windows 2000, you’re out of luck. Instead, the best you could do is retrieve all the instances of the Win32_Product class, then check each instance to see if the caption includes the term Microsoft Office.

Second, the preceding query returns information for any piece of software that has the term Microsoft Office somewhere in its name. You’ll get the scoop on Microsoft Office Professional Edition 2003 all right, but you’ll also get back information for applications like Microsoft Producer for Microsoft Office PowerPoint 2003. Consequently, you might have to further modify this script to ensure that you get back only information about the “real” Microsoft Office.

And before you ask: yes, version information is stored in the registry, but, sadly, it’s not always clear where in the registry to get this information. The location depends on the version of Office installed on a machine, as well as whether this was a clean install or an upgrade of an earlier version of Office. Which means that querying the registry to find out what version of Word is installed on a computer can also be a bit tricky, particularly in organizations where you are likely to have computers running different versions of Office.

So then how the heck do you determine the version of Word installed on a computer? Well, after giving it a bit of thought, we decided the best way was to just ask Word. Here’s a script that creates an instance of Microsoft Word, echoes back the version and build numbers, and then terminates that instance of Word:

Set objWord = CreateObject("Word.Application")
Wscript.Echo "Version: " & objWord.Version
Wscript.Echo "Build: " & objWord.Build
objWord.Quit

Four little lines of code, and pretty much guaranteed to work. On top of that, the instance of Word you create runs in an invisible window, so you won’t even see Word pop up on the screen. What more could you ask for?

If you want to find out the version of Word installed on a remote computer, just add that computer name as the optional second parameter passed to CreateObject. This modified script grabs the version of Word installed on the remote computer atl-ws-01:

Set objWord = CreateObject("Word.Application", "atl-ws-01")
Wscript.Echo "Version: " & objWord.Version
Wscript.Echo "Build: " & objWord.Build
objWord.Quit

Sure, it might seem like overkill, but ultimately this approach should prove easier and more reliable than using Win32_Product or trying to grab version information from the registry.

Your comment has been posted.   Close
Thank you, your comment requires moderation so it may take a while to appear.   Close
Leave a Comment
  • There are two potential problems with this approach:

    1) If you use CreateObject instead of GetObject(, "Word.Application"), you might close a previously opened (i.e. by the user) instance of word.

    2) If a message appears beacause of an error (i.e. the office activation wizard or a warning message etc) while the window is invisible, you application or script will hang...

  • Just get this registry get value and grab the version number from the end

         Dim keyPath As String = "CLSID\{000209FF-0000-0000-C000-000000000046}\ProgID"

         Dim regKey As Microsoft.Win32.RegistryKey = Microsoft.Win32.Registry.ClassesRoot.OpenSubKey(keyPath, False)

         Dim data As String = CType(regKey.GetValue(Nothing, defaultVersion), String)

    I'm sure you can do the same in script