判断 Office 版本
office97 : 8.0
office2000 : 9.0
officeXP(2002) : 10.0
office2003 : 11.0
office2007: 12.0
office2010 : 14.0
office2013: 15.0
MsgBoxThisWorkbook.CalculationVersion 获取一个数字,该数字指示上次对工作簿进行完全重新计算的 Excel的版本。
最右边四位是计算引擎的次版本号,其它位(左边)是Microsoft Office Excel的主版本。
例子 114210
11 是 Excel 11, i.e. Excel2003
92512
9 是 Excel 9
0 没有进行过计算是 0!!!
Excel 97: 8
Excel XP:10
FileFormat例子:
SubxlFileVersion()
Dim Typ AsString
Select CaseActiveWorkbook.FileFormat
Case-4143: Typ = "Excel 2000 et plus"
Case 16:Typ = "Excel 2.1"
Case 29:Typ = "Excel 3"
Case 33:Typ = "Sheet Excel 4"
Case 35:Typ = "Workbook Excel 4"
Case 39:Typ = "Excel 5"
Case 43:Typ = "Excel 97/2000& 5/95"
CaseElse: Typ = "Unknown"
End Select
MsgBox "File format: "& Typ & " !",64
End Sub
方法二:
SubExcel_Ver()
Dim X, Y As String
X = Application.Version
select case X
case 8#
Y = "97"
case 9#
Y = "2000"
case 11#
Y = "2003"
end select
MsgBox X
MsgBox Y, , "Excel版本"
EndSub
Public Sub技巧1_001()
Dim myVersion As String
Select Case Application.Version
Case "8.0"
myVersion = "97"
Case "9.0"
myVersion = "2000"
Case "10.0"
myVersion = "2002"
Case "11.0"
myVersion = "2003"
Case Else
myVersion = "版本未知"
End Select
MsgBox "Excel 版本是: " &myVersion
End Sub
本程序仅适用于Excel 2003(11.0),如果当前版本不是2003则退出
If Application.Version<> "11.0" Then MsgBox "本代码仅在 Excel2003 下可使用! ", vbOKOnly + vbCritical, "Keanjeason": ExitSub
SubxlFileVersion()'获取版本号
Dim Typ AsString
Select CaseActiveWorkbook.FileFormat
Case -4143: Typ = "Excel 2000 et plus"
Case 16: Typ = "Excel 2.1"
Case 29: Typ = "Excel 3"
Case 33: Typ = "Sheet Excel 4"
Case 35: Typ = "Workbook Excel 4"
Case 39: Typ = "Excel 5"
Case 43: Typ = "Excel 97/2000&5/95"
Case Else: Typ = "Unknown"
End Select
MsgBox "File format: "& Typ & " !",64
End Sub