Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Programatically determining the version of Office installed 1

Status
Not open for further replies.

cdipaolo

Programmer
May 1, 2002
36
US
I am working with an application that uses Office Web Components - this uses a different DLL depending on if the user has Office 2002 or later. Is there a way to programatically determine which version of Office a user has installed?
 
Users can have different components of Office installed, but most will have Word, so you can check which version of Word is installed using automation. Office 2002 (XP) is version 10.0, so you just need to know if the version is greater than 9.0
Code:
Public Function GetOfficeVersion() As Single
On Error GoTo ErrHandler

  Dim wd As Word.Application
  
  Set wd = CreateObject("Word.Application")
  
  If Not wd Is Nothing Then
    GetOfficeVersion = CSng(wd.Version)
    wd.Quit False
    Set wd = Nothing
  End If
  
ExitHere:
  Exit Function
ErrHandler:
  Debug.Print "Error: " & Err & "-" & Err.Description
  Resume ExitHere
End Function

Public Function 2002orLater() As Boolean
On Error GoTo ErrHandler

  2002orLater = (GetOfficeVersion > 9#)

ExitHere:
  Exit Function
ErrHandler:
  Debug.Print Err, Err.Description
  Resume ExitHere
End Function

VBSlammer
redinvader3walking.gif

[sleeping]Unemployed in Houston, Texas
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top