Solved

Detect Version of MSAccess

Posted on 2001-06-22
8
216 Views
Last Modified: 2010-05-02
I am using a VB prog to open an access database.  It will open a A2k database if A2k is installed, otherwise it will open A97 version.

I simply need to determine if A2k is installed on the machine, without opening Access to do it.

Thanks,

JS
0
Comment
Question by:jdlsmith
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
8 Comments
 
LVL 3

Expert Comment

by:jrspano
ID: 6219455
why not find the file msaccess.exe and then get the version of it 2000 is 9.0.0.buildversion

i think 97 is version 8.0.0
0
 
LVL 1

Author Comment

by:jdlsmith
ID: 6219463
How do you get the version?
0
 
LVL 1

Author Comment

by:jdlsmith
ID: 6219475
How do you get the version?
0
Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

 
LVL 3

Expert Comment

by:jrspano
ID: 6219478
here is code from freevbcode.com to get the paths to office products

Option Explicit

Private Declare Function RegOpenKeyEx Lib "advapi32.dll" Alias _
   "RegOpenKeyExA" (ByVal hKey As Long, _
   ByVal lpSubKey As String, ByVal ulOptions As Long, _
   ByVal samDesired As Long, phkResult As Long) _
   As Long

Private Declare Function RegQueryValueEx Lib "advapi32.dll" _
   Alias "RegQueryValueExA" (ByVal hKey As Long, ByVal _
   lpValueName As String, ByVal lpReserved As Long, _
   lpType As Long, ByVal lpData As String, lpcbData As Long) _
   As Long
                                                                                                 
Private Declare Function RegCloseKey Lib "advapi32.dll" _
   (ByVal hKey As Long) As Long

Private Const REG_SZ As Long = 1
Private Const KEY_ALL_ACCESS = &H3F
Private Const HKEY_LOCAL_MACHINE = &H80000002

Code:


'*****************************************************
'These functions return the path to the specified office
'application or a 0-length string if the application does not
'exist on the machine.  This is one good way to check whether a
'specific office application is present before trying to run
'automation code for that application
'*****************************************************
Public Function GetWordPath() As String
    GetWordPath = GetOfficeAppPath("Word.Application")
End Function

Public Function GetExcelPath() As String
    GetExcelPath = GetOfficeAppPath("Excel.Application")
End Function

Public Function GetAccessPath() As String
    GetAccessPath = GetOfficeAppPath("Access.Application")
End Function

Public Function GetOutlookPath() As String
    GetOutlookPath = GetOfficeAppPath("Outlook.Application")
End Function

Public Function GetPowerPointPath() As String
    GetPowerPointPath = _
       GetOfficeAppPath("PowerPoint.Application")
End Function

Public Function GetFrontPagePath() As String
    GetFrontPagePath = GetOfficeAppPath("FrontPage.Application")
End Function

Private Function GetOfficeAppPath(ByVal ProgID As String) _
   As String

Dim lKey As Long
Dim lRet As Long
Dim sClassID As String
Dim sAns As String
Dim lngBuffer As Long
Dim lPos As Long

   'GetClassID
   lRet = RegOpenKeyEx(HKEY_LOCAL_MACHINE, _
          "Software\Classes\" & ProgID & "\CLSID", 0&, _
           KEY_ALL_ACCESS, lKey)
   If lRet = 0 Then
 
      lRet = RegQueryValueEx(lKey, "", 0&, REG_SZ, "", lngBuffer)
      sClassID = Space(lngBuffer)
      lRet = RegQueryValueEx(lKey, "", 0&, REG_SZ, sClassID, _
          lngBuffer)

      'drop null-terminator
      sClassID = Left(sClassID, lngBuffer - 1)
      RegCloseKey lKey
   End If
   
   
   'Get AppPath
    lRet = RegOpenKeyEx(HKEY_LOCAL_MACHINE, _
        "Software\Classes\CLSID\" & sClassID & _
        "\LocalServer32", 0&, KEY_ALL_ACCESS, lKey)
 
  If lRet = 0 Then
      lRet = RegQueryValueEx(lKey, "", 0&, REG_SZ, "", lngBuffer)
      sAns = Space(lngBuffer)
      lRet = RegQueryValueEx(lKey, "", 0&, REG_SZ, sAns, _
        lngBuffer)
      sAns = Left(sAns, lngBuffer - 1)
     
      RegCloseKey lKey
   End If
   
   
    'Sometimes the registry will return a switch
       'beginning with "/" e.g., "/automation"
   
    lPos = InStr(sAns, "/")
        If lPos > 0 Then
            sAns = Trim(Left(sAns, lPos - 1))
        End If
   
    GetOfficeAppPath = sAns
   
End Function
0
 
LVL 3

Accepted Solution

by:
jrspano earned 300 total points
ID: 6219493
once you have the path then use this


set a refference to ms scripting runtime

Dim f As New FileSystemObject
Dim s As String

s = f.GetFileVersion(path and filename)
this will give you the version
0
 
LVL 3

Expert Comment

by:jrspano
ID: 6219521
here is the example put together

make a project with 1 form and add a command button with name command1 cut and paste code below


Option Explicit
Private Declare Function RegOpenKeyEx Lib "advapi32.dll" Alias _
  "RegOpenKeyExA" (ByVal hKey As Long, _
  ByVal lpSubKey As String, ByVal ulOptions As Long, _
  ByVal samDesired As Long, phkResult As Long) _
  As Long

Private Declare Function RegQueryValueEx Lib "advapi32.dll" _
  Alias "RegQueryValueExA" (ByVal hKey As Long, ByVal _
  lpValueName As String, ByVal lpReserved As Long, _
  lpType As Long, ByVal lpData As String, lpcbData As Long) _
  As Long
                                                                                                 
Private Declare Function RegCloseKey Lib "advapi32.dll" _
  (ByVal hKey As Long) As Long

Private Const REG_SZ As Long = 1
Private Const KEY_ALL_ACCESS = &H3F
Private Const HKEY_LOCAL_MACHINE = &H80000002



'*****************************************************
'These functions return the path to the specified office
'application or a 0-length string if the application does not
'exist on the machine.  This is one good way to check whether a
'specific office application is present before trying to run
'automation code for that application
'*****************************************************
Public Function GetWordPath() As String
   GetWordPath = GetOfficeAppPath("Word.Application")
End Function

Public Function GetExcelPath() As String
   GetExcelPath = GetOfficeAppPath("Excel.Application")
End Function

Public Function GetAccessPath() As String
   GetAccessPath = GetOfficeAppPath("Access.Application")
End Function

Public Function GetOutlookPath() As String
   GetOutlookPath = GetOfficeAppPath("Outlook.Application")
End Function

Public Function GetPowerPointPath() As String
   GetPowerPointPath = _
      GetOfficeAppPath("PowerPoint.Application")
End Function

Public Function GetFrontPagePath() As String
   GetFrontPagePath = GetOfficeAppPath("FrontPage.Application")
End Function

Private Function GetOfficeAppPath(ByVal ProgID As String) _
  As String

Dim lKey As Long
Dim lRet As Long
Dim sClassID As String
Dim sAns As String
Dim lngBuffer As Long
Dim lPos As Long

  'GetClassID
  lRet = RegOpenKeyEx(HKEY_LOCAL_MACHINE, _
         "Software\Classes\" & ProgID & "\CLSID", 0&, _
          KEY_ALL_ACCESS, lKey)
  If lRet = 0 Then

     lRet = RegQueryValueEx(lKey, "", 0&, REG_SZ, "", lngBuffer)
     sClassID = Space(lngBuffer)
     lRet = RegQueryValueEx(lKey, "", 0&, REG_SZ, sClassID, _
         lngBuffer)

     'drop null-terminator
     sClassID = Left(sClassID, lngBuffer - 1)
     RegCloseKey lKey
  End If
 
   
  'Get AppPath
   lRet = RegOpenKeyEx(HKEY_LOCAL_MACHINE, _
       "Software\Classes\CLSID\" & sClassID & _
       "\LocalServer32", 0&, KEY_ALL_ACCESS, lKey)

 If lRet = 0 Then
     lRet = RegQueryValueEx(lKey, "", 0&, REG_SZ, "", lngBuffer)
     sAns = Space(lngBuffer)
     lRet = RegQueryValueEx(lKey, "", 0&, REG_SZ, sAns, _
       lngBuffer)
     sAns = Left(sAns, lngBuffer - 1)
     
     RegCloseKey lKey
  End If
   
   
   'Sometimes the registry will return a switch
      'beginning with "/" e.g., "/automation"
   
   lPos = InStr(sAns, "/")
       If lPos > 0 Then
           sAns = Trim(Left(sAns, lPos - 1))
       End If
   
   GetOfficeAppPath = sAns
   
End Function


Private Sub Command1_Click()

Dim s As String
Dim a As String
s = GetAccessPath

Dim f As New FileSystemObject

a = f.GetFileVersion(s)  'a has version here

if left$(a,1) = "9" then
  'access2000
endif


End Sub
0
 
LVL 1

Author Comment

by:jdlsmith
ID: 6219539
Perfect!  appreciate the other code too (i'll implement it later)

Thanks!

JS
0
 
LVL 3

Expert Comment

by:jrspano
ID: 6219559
glad i could help!
0

Featured Post

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question