- Const HKEY_LOCAL_MACHINE = &H80000002&
- 'I have commented the types as VBScript does not
- 'use them
- Dim fs 'As Object
- Dim strComputer 'As String
- Dim objReg 'As Object
- Dim strKeyPathOrg 'As String
- Dim strKeyPath 'As String
- Dim strValueName 'As String
- Dim arrSubKeys 'As Variant
- Dim subkey 'As Variant
- 'Mostly strValue is a string, but it can be null
- 'and in Access, you cannot have null in a string
- Dim strValue 'As Variant
- Dim strResult 'As String
- Set fs = CreateObject("Scripting.FileSystemObject")
- strComputer = "."
- Set objReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" _
- & strComputer & "\root\default:StdRegProv")
- strKeyPathOrg = "SOFTWARE\Microsoft\Office"
- strKeyPath = strKeyPathOrg
- strValueName = "Path"
- strKeyPath = strKeyPathOrg
- objReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubKeys
- For Each subkey In arrSubKeys
- Select Case subkey
- Case "14.0"
- strKeyPath = strKeyPathOrg & "\" & subkey & "\Access\InstallRoot\"
- objReg.GetStringValue HKEY_LOCAL_MACHINE, strKeyPath, strValueName, strValue
- If Not IsNull(strValue) Then
- If fs.FileExists(strValue & "msaccess.exe") Then
- strResult = strResult & "Has Access 2010" & vbCrLf
- End If
- End If
- Case "12.0"
- strKeyPath = strKeyPathOrg & "\" & subkey & "\Access\InstallRoot\"
- objReg.GetStringValue HKEY_LOCAL_MACHINE, strKeyPath, strValueName, strValue
- If Not IsNull(strValue) Then
- If fs.FileExists(strValue & "msaccess.exe") Then
- strResult = strResult & "Has Access 2007" & vbCrLf
- End If
- End If
- Case "11.0"
- strKeyPath = strKeyPathOrg & "\" & subkey & "\Access\InstallRoot\"
- objReg.GetStringValue HKEY_LOCAL_MACHINE, strKeyPath, strValueName, strValue
- If Not IsNull(strValue) Then
- If fs.FileExists(strValue & "msaccess.exe") Then
- strResult = strResult & "Has Access 2003" & vbCrLf
- End If
- End If
- Case "10.0"
- strKeyPath = strKeyPathOrg & "\" & subkey & "\Access\InstallRoot\"
- objReg.GetStringValue HKEY_LOCAL_MACHINE, strKeyPath, strValueName, strValue
- If Not IsNull(strValue) Then
- If fs.FileExists(strValue & "msaccess.exe") Then
- strResult = strResult & "Has Access XP" & vbCrLf
- End If
- End If
- Case "9.0"
- strKeyPath = strKeyPathOrg & "\" & subkey & "\Access\InstallRoot\"
- objReg.GetStringValue HKEY_LOCAL_MACHINE, strKeyPath, strValueName, strValue
- If Not IsNull(strValue) Then
- If fs.FileExists(strValue & "msaccess.exe") Then
- strResult = strResult & "Has Access 2000" & vbCrLf
- End If
- End If
- Case "8.0"
- strKeyPath = strKeyPathOrg & "\" & subkey & "\Access\InstallRoot\"
- objReg.GetStringValue HKEY_LOCAL_MACHINE, strKeyPath, strValueName, strValue
- If Not IsNull(strValue) Then
- If fs.FileExists(strValue & "msaccess.exe") Then
- strResult = strResult & "Has Access 97" & vbCrLf
- End If
- End If
- End Select
- Next
- MsgBox strResult
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.
List All Installed Versions of Access
From Wiki
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.



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