5

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.

HvS
  • 504
  • 1
  • 14
  • 22
  • 1
    See that [Link](http://www.vbforums.com/showthread.php?402020-FAQ-s-OD-How-do-I-programmatically-determine-the-version-of-an-Office-App) – 0m3r Jul 30 '15 at 09:07
  • @Omar: Thanks for the link. Seems I got my naming convention wrong - I am actually looking for the revision+build versions. Updated my question. – HvS Jul 30 '15 at 09:35

2 Answers2

5

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

HvS
  • 504
  • 1
  • 14
  • 22
Maxime Porté
  • 1,034
  • 8
  • 13
  • A note to anyone using OLE to execute this solution, or anyone having trouble accessing the `VBProject` object via `ThisWorkbook`. You can also access the `References` object in this manner: `Application.VBE.VBProjects.Item(1).References`. During my tests `VBProjects` always only had one `Item`, but I presume that will not always be the case. – HvS Jul 30 '15 at 11:51
4

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"
Slai
  • 22,144
  • 5
  • 45
  • 53