使用VBA查找MS Office修订版和内部版本 [英] Finding MS Office revision and build version, using VBA
问题描述
可以使用Application.Version
找到Office应用程序的主要版本和次要版本.
The major and minor version of an office application can be found using Application.Version
.
返回示例:
15.0 = Office 2013
12.0 = Office 2007
我需要Office应用程序的修订和生成版本,例如:
I require the revision and build version of the office application, example:
Microsoft Office PowerPoint 2007原始文件:major.minor: 12.0
revision.build: 4518.1014
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
Microsoft Office PowerPoint 2007 SP2: major.minor: 12.0
revision.build: 6425.1000
问题:是否可以通过使用VBA 查找办公应用程序的修订和生成版本?
Question: Is there a way of finding the revision and build version of an office application, using VBA?
问题已更新:我的命名约定错误-寻找Office应用程序的修订版和内部版本,而不是次要版本.
Question updated: Naming convention mistake on my side - Looking for the revision and build version of an office application, not the minor version.
推荐答案
VBA没有直接执行此操作的函数,您将必须编写一个函数来执行此操作:
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
在chkref.name上过滤Excel/Office/Word
Filter Excel / Office / Word on the chkref.name
这篇关于使用VBA查找MS Office修订版和内部版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!