• How to find Access version in code

    Author
    Topic
    #479928

    Is there a way to use VBA code to query Access for the version?

    I would like to create an If statement that will do one thing for Access 2010 and a different thing for Acess 2003.

    Thank for your help

    Viewing 10 reply threads
    Author
    Replies
    • #1305865

      Richard,

      Here’s a UDF that will do the trick:

      Code:
      Public Function AccessVersionID() As String
      
      
         Select Case SysCmd(acSysCmdAccessVer)
               Case 7: AccessVersionID = "95"
               Case 8: AccessVersionID = "97"
               Case 9: AccessVersionID = "2000"
               Case 10: AccessVersionID = "2002"
               Case 11: AccessVersionID = "2003"
               Case 12: AccessVersionID = "2007"
               Case 13: AccessVersionID = "Pirated!"
               Case 14: AccessVersionID = "2010"
               Case Else: AccessVersionID = "Unknown"
         End Select
      
       End Function            'AccessVersionID()
      

      :cheers:

      May the Forces of good computing be with you!

      RG

      PowerShell & VBA Rule!
      Computer Specs

      • #1305927

        This is GREAT. Thank for your help.

        • #1305960

          You can also use
          Application.Version
          This returns the Office Suite Number

          So 2010 = 14.0, 2007 = 12.0, 2003 = 11.0, XP = 10.0, 2000 = 9.0 etc

          No 13. Bit superstitious the MS Lot! 2010 is 14.0 not 13.

    • #1305962

      Andrew,

      Interesting, very Interesting… Could you try out my code and see if it works for 2010 as I don’t have it and maybe it should be changed from 13 to 14 for 2010? :cheers:

      May the Forces of good computing be with you!

      RG

      PowerShell & VBA Rule!
      Computer Specs

      • #1305973

        Andrew,Interesting, very Interesting… Could you try out my code and see if it works for 2010 as I don’t have it and maybe it should be changed from 13 to 14 for 2010? :cheers:

        It is 14.0 in Office 2010.
        Trust me.

    • #1305972

      Indeed, it should be 14 for 2010. And I’d bet dollars/euros to donuuts that the next version will be 15. But as to whether it will be called 2012 or 2013, or something else entirely is pretty much conjecture.

    • #1305980

      Wendell & Andrew,

      Thanks! :cheers:

      P.S. I fixed the code above.

      May the Forces of good computing be with you!

      RG

      PowerShell & VBA Rule!
      Computer Specs

    • #1306346

      Do you now how to deterime the SP level?

      • #1306394

        Application.Build
        Will return Build No.
        If you can map that to the Service Pack you could do it.

    • #1306388

      Coach,

      This works on my Win7 SP1 64 Bit Laptop with Office 2007 SP3.

      Code:
      Option Compare Database
      Option Explicit
       
      Declare Function RegQueryValueEx Lib "advapi32.dll" Alias "RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, lpType As Long, lpData As Any, lpcbData As Long) As Long
      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
      Public Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
      Const HKEY_LOCAL_MACHINE = &H80000002
      Const KEY_QUERY_VALUE = &H1
      
      Sub cmdRead()
          Dim strValue As String * 256
          Dim lngRetval As Long
          Dim lngLength As Long
          Dim lngKey As Long
      
          If RegOpenKeyEx(HKEY_LOCAL_MACHINE, _
              "SOFTWAREWow6432NodeMicrosoftOffice12.0Registration{91120000-0014-0000-0000-0000000FF1CE}", _
              0, KEY_QUERY_VALUE, lngKey) Then
          End If
      
          lngLength = 256
      
          'Retrieve the value of the key
          lngRetval = RegQueryValueEx( _
              lngKey, "SPLevel", 0, 0, ByVal strValue, lngLength)
          MsgBox "Microsoft Office SP Level: " & Left(strValue, lngLength)
      
          'Close the key
          RegCloseKey (lngKey)
          
      End Sub
      

      :cheers:

      May the Forces of good computing be with you!

      RG

      PowerShell & VBA Rule!
      Computer Specs

    • #1306643

      Thanks RG and Andrew.

    • #1306647

      Boyd,

      Please note I checked my desktop which is Win 7 SP-1 w/Office 2003 Pro SP-3 and that Registry Key does not exist! I can’t find any location in the Registry that shows the SP level of Office, however it does show up in the Help About screen of each product.
      Office 2003 Registry: [noparse]HKEY_LOCAL_MACHINESOFTWAREWow6432NodeMicrosoftOffice11.0Registration{90110409-6000-11D3-8CFE-0150048383C9}[/noparse] :cheers:

      Update: I found this in a different location. You could use it but then you’ll need logic to search for different versions.

      Code:
      Windows Registry Editor Version 5.00
      
      [HKEY_CURRENT_USERSoftwareMicrosoftOffice11.0ExcelOptions]
      
      "SP3FirstRun"=dword:00000000
      
      

      Office Version Info:
      2010: http://support.microsoft.com/kb/2121559
      2007: http://support.microsoft.com/kb/928116
      2003: http://labnol.blogspot.com/2005/09/determine-microsoft-office-2003.html

      May the Forces of good computing be with you!

      RG

      PowerShell & VBA Rule!
      Computer Specs

    • #1306680

      RG, Thanks for the update.

      My goal is to determine the SP level. Using Application.Build (click here) may be the easiest method since it works in Access 2003 and later.

      I also found this. API: Get Version of Office Exes (detecting Office patches)

    • #1306687

      Boyd,

      Nice!…

      Here’s a version for any Office App.

      Code:
      Sub AppBuildInfo()
      
      MsgBox "You are currently running " & Application.Name _
          & " version " & Application.Version & ", build " _
          & Application.Build & "."
          
      End Sub
      

      :cheers:

      May the Forces of good computing be with you!

      RG

      PowerShell & VBA Rule!
      Computer Specs

    • #1306689

      I agree. Application.Build sure makes it simple.

      Thanks Andrew for pointing that out. 🙂

    Viewing 10 reply threads
    Reply To: How to find Access version in code

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: