2015-01-26 133 views
0

我无法为Macintosh运行Excel,但由于Excel VBA编译器常量VBA7是在Excel(针对Windows)2010中引入的,因此我认为它也适用于Mac Excel 2011。Excel VBA编译器常量:Mac Excel 2011 <> VBA7?

但是,显然这个代码时,在Mac的Excel 2011运行了“其他”部分(适用于Excel 2007中)编译:

#If VBA7 Then 
    'Set constants here for Excel 2010 or later: 
#Else 
    'Set constants here for Excel 2007 or earlier: 
#End If 

因此,要得到它的谁是Mac的Excel 2011用户工作,我不得不把它改成这样:

#If VBA7 Or Mac Then 
    'Set constants here for Excel for Windows 2010 or later, or Excel for Mac: 
#Else 
    'Set constants here for Excel for Windows 2007 or earlier: 
#End If 

确实的Mac的Excel 2011真的没有VBA7,或者是刚刚在编译器不断的疏忽?

回答

1

Excel for Mac仍然使用VBA 6.5,因此VBA7常量不存在。 Excel Mac 2016的v15.11(150609)仍然如此。

如果你真的想要主机Excel应用程序版本之间的区别,那么你应该使用Application.Version

其中:

5 = Excel 5 
6 = Excel 6 
7 = Excel 95 
8 = Excel 97 
9 = Excel 2000 
10 = Excel 2002 
11 = Excel 2003 
12 = Excel 2007 
14 = Excel 2010 and Excel Mac 2011 
15 = Excel 2013 and Excel Mac 2016 

如果你想在VBA环境的版本,你可以使用: -

Application.VBE.Version