使用 VBA 查找 MS Office 修订版和内部版本
Finding MS Office revision and build version, using VBA
办公应用程序的主要和次要版本可以使用Application.Version
找到。
Return 例子:
15.0 = Office 2013
12.0 = Office 2007
我需要办公应用程序的修订版和构建版,示例:
Microsoft Office PowerPoint 2007 原文:major.minor: 12.0
revision.build: 4518.1014
Microsoft Office PowerPoint 2007 SP2:major.minor: 12.0
revision.build: 6425.1000
问题:有没有办法找到办公应用程序的修订版和内部版本,使用VBA?
问题已更新:我这边的命名约定错误 - 寻找 office 应用程序的修订和构建版本,而不是次要版本。
VBA没有直接做的函数,你必须写一个函数来做:
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
备选方案摘要:
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"
办公应用程序的主要和次要版本可以使用Application.Version
找到。
Return 例子:
15.0 = Office 2013
12.0 = Office 2007
我需要办公应用程序的修订版和构建版,示例:
Microsoft Office PowerPoint 2007 原文:major.minor: 12.0
revision.build: 4518.1014
Microsoft Office PowerPoint 2007 SP2:major.minor: 12.0
revision.build: 6425.1000
问题:有没有办法找到办公应用程序的修订版和内部版本,使用VBA?
问题已更新:我这边的命名约定错误 - 寻找 office 应用程序的修订和构建版本,而不是次要版本。
VBA没有直接做的函数,你必须写一个函数来做:
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备选方案摘要:
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"