Page 1 of 2 12 LastLast
Results 1 to 15 of 16
  1. #1
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    USA
    Posts
    386
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How to find Access version in code

    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
    Richard

  2. #2
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    9,436
    Thanks
    372
    Thanked 1,457 Times in 1,326 Posts
    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()
    Last edited by RetiredGeek; 2011-11-09 at 17:55. Reason: Correct version number for Office 2010
    May the Forces of good computing be with you!

    RG

    PowerShell & VBA Rule!

    My Systems: Desktop Specs
    Laptop Specs

  3. #3
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    USA
    Posts
    386
    Thanks
    0
    Thanked 0 Times in 0 Posts
    This is GREAT. Thank for your help.
    Richard

  4. #4
    5 Star Lounger AndrewKKWalker's Avatar
    Join Date
    Apr 2001
    Location
    Cambridge, UK
    Posts
    1,020
    Thanks
    0
    Thanked 3 Times in 3 Posts
    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.
    Andrew

  5. #5
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    9,436
    Thanks
    372
    Thanked 1,457 Times in 1,326 Posts
    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?
    May the Forces of good computing be with you!

    RG

    PowerShell & VBA Rule!

    My Systems: Desktop Specs
    Laptop Specs

  6. #6
    Super Moderator
    Join Date
    Aug 2001
    Location
    Evergreen, CO, USA
    Posts
    6,624
    Thanks
    3
    Thanked 60 Times in 60 Posts
    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.
    Wendell

  7. #7
    5 Star Lounger AndrewKKWalker's Avatar
    Join Date
    Apr 2001
    Location
    Cambridge, UK
    Posts
    1,020
    Thanks
    0
    Thanked 3 Times in 3 Posts
    Quote Originally Posted by RetiredGeek View Post
    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?
    It is 14.0 in Office 2010.
    Trust me.
    Last edited by AndrewKKWalker; 2011-11-09 at 16:19.
    Andrew

  8. #8
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    9,436
    Thanks
    372
    Thanked 1,457 Times in 1,326 Posts
    Wendell & Andrew,

    Thanks!

    P.S. I fixed the code above.
    May the Forces of good computing be with you!

    RG

    PowerShell & VBA Rule!

    My Systems: Desktop Specs
    Laptop Specs

  9. #9
    3 Star Lounger HiTechCoach's Avatar
    Join Date
    Sep 2011
    Location
    Oklahoma City, OK
    Posts
    200
    Thanks
    0
    Thanked 31 Times in 30 Posts
    Do you now how to deterime the SP level?
    Boyd Trimmell aka HiTechCoach (Access Information here)
    Microsoft MVP - Access Expert
    "If technology doesn't work for people, then it doesn't work."

  10. #10
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    9,436
    Thanks
    372
    Thanked 1,457 Times in 1,326 Posts
    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, _
            "SOFTWARE\Wow6432Node\Microsoft\Office\12.0\Registration\{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
    May the Forces of good computing be with you!

    RG

    PowerShell & VBA Rule!

    My Systems: Desktop Specs
    Laptop Specs

  11. #11
    5 Star Lounger AndrewKKWalker's Avatar
    Join Date
    Apr 2001
    Location
    Cambridge, UK
    Posts
    1,020
    Thanks
    0
    Thanked 3 Times in 3 Posts
    Application.Build
    Will return Build No.
    If you can map that to the Service Pack you could do it.
    Andrew

  12. #12
    3 Star Lounger HiTechCoach's Avatar
    Join Date
    Sep 2011
    Location
    Oklahoma City, OK
    Posts
    200
    Thanks
    0
    Thanked 31 Times in 30 Posts
    Thanks RG and Andrew.
    Boyd Trimmell aka HiTechCoach (Access Information here)
    Microsoft MVP - Access Expert
    "If technology doesn't work for people, then it doesn't work."

  13. #13
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    9,436
    Thanks
    372
    Thanked 1,457 Times in 1,326 Posts
    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: HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\ Office\11.0\Registration\{90110409-6000-11D3-8CFE-0150048383C9}

    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_USER\Software\Microsoft\Office\11.0\Excel\Options]
    
    "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/d...fice-2003.html
    Last edited by RetiredGeek; 2011-11-14 at 11:57. Reason: New Info
    May the Forces of good computing be with you!

    RG

    PowerShell & VBA Rule!

    My Systems: Desktop Specs
    Laptop Specs

  14. #14
    3 Star Lounger HiTechCoach's Avatar
    Join Date
    Sep 2011
    Location
    Oklahoma City, OK
    Posts
    200
    Thanks
    0
    Thanked 31 Times in 30 Posts
    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)
    Boyd Trimmell aka HiTechCoach (Access Information here)
    Microsoft MVP - Access Expert
    "If technology doesn't work for people, then it doesn't work."

  15. #15
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    9,436
    Thanks
    372
    Thanked 1,457 Times in 1,326 Posts
    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
    May the Forces of good computing be with you!

    RG

    PowerShell & VBA Rule!

    My Systems: Desktop Specs
    Laptop Specs

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •