Since, the introduction of Office 365 (Now called Microsoft 365), I believe, Office 2016, we now have to use the Office Build Number for troubleshooting the onslaught of bugs we have been facing.
Now, the Build No. can be accessed through the interface:
File -> Account -> About Access
but not all users are comfortable doing this and as a developer it is always best not to put the burden on your users for such information.
So I set out to find out if there was some way to retrieve the Office Build Number through VBA.
Getting the Office Build Number
Once again, it all comes down to knowing where to look, which registry key to read:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\ClickToRun\Configuration\VersionToReport
Once you know that, then you can simply build a function around it, like:
'---------------------------------------------------------------------------------------
' Procedure : Office_BuildNo
' Author : Daniel Pineault, CARDA Consultants Inc.
' Website : http://www.cardaconsultants.com
' Purpose : Retrieve the Office CTR Build No.
' "" indicates not CTR, registry key not found
' Copyright : The following is release as Attribution-ShareAlike 4.0 International
' (CC BY-SA 4.0) - https://creativecommons.org/licenses/by-sa/4.0/
' Req'd Refs: Late Binding -> none required
'
' Usage:
' ~~~~~~
' ? Office_BuildNo
' Returns -> 16.0.11901.20218
'
' Revision History:
' Rev Date(yyyy-mm-dd) Description
' **************************************************************************************
' 1 2020-12-23 Initial Release
'---------------------------------------------------------------------------------------
Public Function Office_BuildNo() As String
On Error GoTo Error_Handler
Dim oShell As Object
Dim sRegKey As String
Set oShell = CreateObject("WScript.Shell")
sRegKey = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\ClickToRun\Configuration\VersionToReport"
Office_BuildNo = oShell.RegRead(sRegKey)
Error_Handler_Exit:
On Error Resume Next
If Not oShell Is Nothing Then Set oShell = Nothing
Exit Function
Error_Handler:
If Err.Number = -2147024894 Then 'Invalid root in registry key
'Registry Key not found, not CTR, probably an older version
Else
MsgBox "The following error has occured" & vbCrLf & vbCrLf & _
"Error Number: " & Err.Number & vbCrLf & _
"Error Source: Office_BuildNo" & vbCrLf & _
"Error Description: " & Err.Description & _
Switch(Erl = 0, "", Erl <> 0, vbCrLf & "Line No: " & Erl) _
, vbOKOnly + vbCritical, "An Error has Occured!"
End If
Resume Error_Handler_Exit
End Function
A simpler method that will work for any version of access (not just 365)
This looks at the property of the actual MS ACCESS file:
CreateObject(“Scripting.FileSystemObject”).GetFileVersion(SysCmd(acSysCmdAccessDir) & “\msaccess.exe”)
From past discussions, I was told the exe file version does not necessarily equate to the Office build no.
Also, note SysCmd(acSysCmdAccessVer) returns the trailing \ so you don’t need it to precede the msaccess.exe string.