Login or Sign Up to become a member!
LessThanDot Sit Logo

LessThanDot

Community Wiki

Less Than Dot is a community of passionate IT professionals and enthusiasts dedicated to sharing technical knowledge, experience, and assistance. Inside you will find reference materials, interesting technical discussions, and expert tips and commentary. Once you register for an account you will have immediate access to the forums and all past articles and commentaries.

LTD Social Sitings

Lessthandot twitter Lessthandot Linkedin Lessthandot friendfeed Lessthandot facebook Lessthandot rss

Note: Watch for social icons on posts by your favorite authors to follow their postings on these and other social sites.

Navigation

Google Ads

List All Installed Versions of Access

From Wiki

Jump to: navigation, search

You can use the registry to get a list of versions of Access installed on the current machine. This code will run in Access, but is mainly intended for script. If more than one version is returned, you may wish to consider which to use to open a particular mdb, because it is not always wise to use the currently registed version.

  1. Const HKEY_LOCAL_MACHINE = &H80000002&
  2.  
  3. 'I have commented the types as VBScript does not
  4. 'use them
  5. Dim fs 'As Object
  6. Dim strComputer 'As String
  7. Dim objReg 'As Object
  8. Dim strKeyPathOrg 'As String
  9. Dim strKeyPath 'As String
  10. Dim strValueName 'As String
  11. Dim arrSubKeys 'As Variant
  12. Dim subkey 'As Variant
  13. 'Mostly strValue is a string, but it can be null
  14. 'and in Access, you cannot have null in a string
  15. Dim strValue 'As Variant
  16. Dim strResult 'As String
  17.  
  18. Set fs = CreateObject("Scripting.FileSystemObject")
  19.  
  20. strComputer = "."
  21. Set objReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" _
  22.     & strComputer & "\root\default:StdRegProv")
  23.    
  24. strKeyPathOrg = "SOFTWARE\Microsoft\Office"
  25. strKeyPath = strKeyPathOrg
  26. strValueName = "Path"
  27.  
  28. strKeyPath = strKeyPathOrg
  29. objReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubKeys
  30.  
  31. For Each subkey In arrSubKeys
  32.  
  33.     Select Case subkey
  34.       Case "14.0"
  35.       strKeyPath = strKeyPathOrg & "\" & subkey & "\Access\InstallRoot\"
  36.       objReg.GetStringValue HKEY_LOCAL_MACHINE, strKeyPath, strValueName, strValue
  37.       If Not IsNull(strValue) Then
  38.             If fs.FileExists(strValue & "msaccess.exe") Then
  39.                strResult = strResult & "Has Access 2010" & vbCrLf
  40.             End If
  41.       End If
  42.  
  43.       Case "12.0"
  44.       strKeyPath = strKeyPathOrg & "\" & subkey & "\Access\InstallRoot\"
  45.       objReg.GetStringValue HKEY_LOCAL_MACHINE, strKeyPath, strValueName, strValue
  46.       If Not IsNull(strValue) Then
  47.             If fs.FileExists(strValue & "msaccess.exe") Then
  48.                strResult = strResult & "Has Access 2007" & vbCrLf
  49.             End If
  50.       End If
  51.  
  52.       Case "11.0"
  53.       strKeyPath = strKeyPathOrg & "\" & subkey & "\Access\InstallRoot\"
  54.       objReg.GetStringValue HKEY_LOCAL_MACHINE, strKeyPath, strValueName, strValue
  55.       If Not IsNull(strValue) Then
  56.             If fs.FileExists(strValue & "msaccess.exe") Then
  57.                strResult = strResult & "Has Access 2003" & vbCrLf
  58.             End If
  59.       End If
  60.  
  61.       Case "10.0"
  62.       strKeyPath = strKeyPathOrg & "\" & subkey & "\Access\InstallRoot\"
  63.       objReg.GetStringValue HKEY_LOCAL_MACHINE, strKeyPath, strValueName, strValue
  64.       If Not IsNull(strValue) Then
  65.             If fs.FileExists(strValue & "msaccess.exe") Then
  66.                strResult = strResult & "Has Access XP" & vbCrLf
  67.             End If
  68.       End If
  69.  
  70.       Case "9.0"
  71.       strKeyPath = strKeyPathOrg & "\" & subkey & "\Access\InstallRoot\"
  72.       objReg.GetStringValue HKEY_LOCAL_MACHINE, strKeyPath, strValueName, strValue
  73.       If Not IsNull(strValue) Then
  74.             If fs.FileExists(strValue & "msaccess.exe") Then
  75.                strResult = strResult & "Has Access 2000" & vbCrLf
  76.             End If
  77.       End If
  78.  
  79.       Case "8.0"
  80.       strKeyPath = strKeyPathOrg & "\" & subkey & "\Access\InstallRoot\"
  81.       objReg.GetStringValue HKEY_LOCAL_MACHINE, strKeyPath, strValueName, strValue
  82.       If Not IsNull(strValue) Then
  83.             If fs.FileExists(strValue & "msaccess.exe") Then
  84.                strResult = strResult & "Has Access 97" & vbCrLf
  85.             End If
  86.       End If
  87.     End Select
  88.  
  89. Next
  90.  
  91. MsgBox strResult

666 Rating: 0.0/5 (0 votes cast)