Finding MS Office revision and build version, using VBA

核能气质少年 提交于 2019-12-05 10:02:08
Maxime Porté

VBA does not have a function to do it directly, you will have to write a function to do it:

Public Sub test()
    Dim version As String
    Dim chkref As Object

    ' List of references
    For Each chkref In ThisWorkbook.VBProject.References
        version = RetrieveDllVersion(chkref.fullpath)
        major = RetrievePart(version, 0)
        majorup = RetrievePart(version, 1)
        minor = RetrievePart(version, 2)
        minorup = RetrievePart(version, 3)

        MsgBox chkref.Name & " : " & major & "." & majorup & "." & minor & "." & minorup
    Next
End Sub

Private Function RetrieveDllVersion(ByVal dll As String) As String
  Dim fso As Object 'Scripting.FileSystemObject
  Set fso = CreateObject("Scripting.FileSystemObject")
  RetrieveDllVersion = fso.GetFileVersion(dll)
End Function

Private Function RetrievePart(ByVal version As String, ByVal pos As Integer) As String
    RetrievePart = Split(version, ".")(pos)
End Function

Filter Excel / Office / Word on the chkref.name

Summary of alternatives :

Application.Version                                             "16.0"
Application.Build                                               "16.0.8431"
Application.BuildFull                                           "16.0.8431.0"

CreateObject("Scripting.FileSystemObject") _
    .GetFileVersion(Application.Path & "\WINWORD.exe")          "16.0.8431.2280"
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!