Finding MS Office revision and build version, using VBA

放肆的年华 提交于 2019-12-07 05:46:52

问题


The major and minor version of an office application can be found using Application.Version.

Return examples:

15.0 = Office 2013
12.0 = Office 2007

I require the revision and build version of the office application, example:

Microsoft Office PowerPoint 2007 Original: major.minor: 12.0 revision.build: 4518.1014

Microsoft Office PowerPoint 2007 SP2: major.minor: 12.0 revision.build: 6425.1000

Question: Is there a way of finding the revision and build version of an office application, using VBA?

Question updated: Naming convention mistake on my side - Looking for the revision and build version of an office application, not the minor version.


回答1:


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




回答2:


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"


来源:https://stackoverflow.com/questions/31718490/finding-ms-office-revision-and-build-version-using-vba

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!