Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Finding MS Office revision and build version, using VBA

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.

like image 327
HvS Avatar asked Jul 30 '15 08:07

HvS


2 Answers

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

like image 186
Maxime Porté Avatar answered Oct 04 '22 20:10

Maxime Porté


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"
like image 37
Slai Avatar answered Oct 04 '22 20:10

Slai