简单应用程序对象示例显示 Excel 和 VBE 版本

Sub DisplayExcelVersions()

    MsgBox "The version of Excel is " & Application.Version
    MsgBox "The version of the VBE is " & Application.VBE.Version

End Sub

使用 Application.Version 属性对于确保代码仅在兼容版本的 Excel 上运行非常有用。