Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Determine Office VErsion and language

642 views
Skip to first unread message

John Koswalski

unread,
Nov 13, 2003, 3:46:03 AM11/13/03
to
Hello,,

How can I use VBScript to determine the offece version and language.

Thank you


Torgeir Bakken (MVP)

unread,
Nov 13, 2003, 7:09:20 AM11/13/03
to
John Koswalski wrote:

> How can I use VBScript to determine the offece version and language.

Hi

Here is a script that finds the newest Office version installed on a computer
based on the existence of the following registry keys:

HKLM\SOFTWARE\Microsoft\Office\11.0\Common\InstallRoot ' Office 2003
HKLM\SOFTWARE\Microsoft\Office\10.0\Common\InstallRoot ' Office 2002 (XP)
HKLM\SOFTWARE\Microsoft\Office\9.0\Common\InstallRoot ' Office 2000
HKLM\SOFTWARE\Microsoft\Office\8.0\Common\InstallRoot ' Office 97

WScript.Echo "Version of Office installed (0 eq. none): " & GetOfficeVer()

Function GetOfficeVer()

sRegPre = "HKLM\SOFTWARE\Microsoft\Office\"
sRegPost = "\Common\InstallRoot\"
Select Case True
Case RegKeyExists(sRegPre & "11.0" & sRegPost)
sOfficeVer = "2003"
Case RegKeyExists(sRegPre & "10.0" & sRegPost)
sOfficeVer = "2002"
Case RegKeyExists(sRegPre & "9.0" & sRegPost)
sOfficeVer = "2000"
Case RegKeyExists(sRegPre & "8.0" & sRegPost)
sOfficeVer = "97"
Case Else
sOfficeVer = "0"
End Select
GetOfficeVer = sOfficeVer
End Function


Function RegKeyExists(ByVal sRegKey)
' Returns True or False based on the existence of a registry key.

Dim sDescription, oShell
Set oShell = CreateObject("WScript.Shell")

RegKeyExists = True
sRegKey = Trim (sRegKey)
If Not Right(sRegKey, 1) = "\" Then
sRegKey = sRegKey & "\"
End If

On Error Resume Next
oShell.RegRead "HKEYNotAKey\"
sDescription = Replace(Err.Description, "HKEYNotAKey\", "")

Err.Clear
oShell.RegRead sRegKey
RegKeyExists = sDescription <> Replace(Err.Description, sRegKey, "")
On Error Goto 0
End Function

--
torgeir
Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and an ONLINE version of the 1328 page
Scripting Guide: http://www.microsoft.com/technet/scriptcenter


Torgeir Bakken (MVP)

unread,
Nov 13, 2003, 8:33:12 AM11/13/03
to
John Koswalski wrote:

> How can I use VBScript to determine the offece version and language.

Hi

I think this should work for the language part:


'By using info from the following:
'http://msdn.microsoft.com/library/en-us/off2000/html/ofobjLanguageSettings.asp

Const msoLanguageIDInstall = 1
Const msoLanguageIDUI = 2

With CreateObject("Word.Application")
.Visible = False
iLanguageID = .LanguageSettings.LanguageID(msoLanguageIDInstall)
.Application.Quit
End With

WScript.Echo "Language ID: " & iLanguageID

' convert the number to a language
sLanguage = Language(iLanguageID)
WScript.Echo "Language: " & sLanguage

Function Language(ByVal iLanguageID)

Set oShell = CreateObject("WScript.Shell")

sLangHex = Right("000" & Hex(iLanguageID), 4)

On Error Resume Next
sLanguage = "" ' Init value
sLanguage = oShell.RegRead("HKLM\SOFTWARE\Classes\MIME\Database\Rfc1766\" _
& sLangHex)
' remove unnecessary stuff
aOSLanguage = Split(sLanguage, ";")
sLanguage = aOSLanguage(UBound(aOSLanguage))
If Instr(sLanguage, "(") > 0 Then
aOSLanguage = Split(sLanguage, "(")
sLanguage = Trim(aOSLanguage(0))
End If

If sLanguage = "" Then
Language = "Unknown"
Else
Language = sLanguage
End If

0 new messages