blabore Posted November 6, 2003 Posted November 6, 2003 (edited) Check what version of Word is installed Does anyone know of a way to check if Word is installed, and what version it is? I currently just try to instanitate a Word Application object, and handle the error to indicate word isn't available, but this is pretty much a hack. Any suggestions would be appreciated. Thanks, Ben Edited November 7, 2003 by blabore Quote -Ben LaBore
Shamil Posted November 11, 2003 Posted November 11, 2003 Ben, For MS Word versions starting 9.0 (2000) you can check the existence of the registry key: [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\<MS Office version>\Access\InstallRoot] e.g. for MS Word 2000 this will be the key: [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\9.0\Access\InstallRoot] For MS Office 97 I think you've to check the existence of the system registry value BinDirPath under [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\8.0] read this value - e.g. I've it here as "BinDirPath"="D:\\Program Files\\MSOffice\\97\\Office" and then concatenate it with winword.exe - it will be: D:\Program Files\MSOffice\97\Office\winword.exe for the sample value above and see if this file exists of not. HTH, Shamil Quote e-mail: shamil-usersATmns.ru
Shamil Posted November 11, 2003 Posted November 11, 2003 Ben, Sorry, I did post wrong registry keys (form MS Access instead of MW Word) - here how they should have been posted: For MS Word versions starting 9.0 (2000) you can check the existence of the registry key: [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\<MS Office version>\Word\InstallRoot] e.g. for MS Word 2000 this will be the key: [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\9.0\Word\InstallRoot] For MS Office 97 I think you've to check the existence of the system registry value BinDirPath under [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\8.0] read this value - e.g. I've it here as "BinDirPath"="D:\\Program Files\\MSOffice\\97\\Office" and then concatenate it with winword.exe - it will be: D:\Program Files\MSOffice\97\Office\winword.exe for the sample value above and see if this file exists of not. HTH, Shamil Quote e-mail: shamil-usersATmns.ru
Shamil Posted November 11, 2003 Posted November 11, 2003 Ben, Here is the function, which should help you (tested with MS Office 2000 only): Public Function MsWordFullPath(ByVal vlngVersion As Long) As String ' Given MS Word version number returns its FullPath if it's installed, empty string ("") otherwise ' Note: MS Office versions supported: 8 and above Dim objRegKey As Microsoft.Win32.RegistryKey Dim strKeyName As String Dim strValueName As String Dim strValue As String strKeyName = "SOFTWARE\\Microsoft\\Office\\" & vlngVersion.ToString & ".0\\Common\\InstallRoot" Select Case vlngVersion Case Is < 8 strValueName = "" strValue = "" Case 8 strValueName = "OfficeBin" Case Is > 8 strValueName = "Path" End Select If Microsoft.VisualBasic.Len(strValueName) > 0 Then objRegKey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(strKeyName, False) If (objRegKey Is Nothing) Then strValue = "" Else strValue = objRegKey.GetValue(strValueName) If Microsoft.VisualBasic.Len(strValue) > 0 Then If Microsoft.VisualBasic.Right(strValue, 1) <> "\" Then strValue = strValue & "\" strValue = strValue & "winword.exe" If Not System.IO.File.Exists(strValue) Then strValue = "" End If objRegKey.Close() End If End If Return (strValue) End Function HTH, Shamil Quote e-mail: shamil-usersATmns.ru
blabore Posted November 11, 2003 Author Posted November 11, 2003 Shamil, Thanks for the replies, that was exactly what I was looking for. -Ben Quote -Ben LaBore
Recommended Posts