大众计算机学习网

专门提供各种电脑教程

判断Excel版本号码的VBA代码

Admin | 2013-12-20 8:53:04 | 被阅次数 | 3690

  通过下面的代码,可以判断出Excel的版本号码,代码如下:共分两种代码。

  第一种代码

  Dim Typ As String

  Select Case ActiveWorkbook.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

  第二种代码

  Dim Typ As String

  Select Case ActiveWorkbook.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