如何确定我的VB代码是否在Office 2016 for Mac上运行?

时间:2015-06-22 21:20:15

标签: vba powerpoint-vba excel-vba-mac mac-office word-vba-mac

是否有条件我可以用来区分我的宏是在Office 2016 for Mac还是Office for Mac 2011上运行

1 个答案:

答案 0 :(得分:4)

在Office 2016 for Mac中,有一个名为MAC_OFFICE_VERSION的新条件,用于测试用户正在运行的VB版本。 以下示例显示了如何在代码中使用它:

Sub VersionConditionals()
#If MAC_OFFICE_VERSION >= 15 Then
    Debug.Print "We are running on Mac 15+"
#Else
    Debug.Print "We are not running on Mac 15+"
#End If
#If Mac Then
    Debug.Print "We are running on a Mac"
#Else
    Debug.Print "We are not running on a Mac"
#End If
End Sub

注意:" #If Mac" Office for Mac 2011中的条件保持不变。

相关问题