I know that I can use conditional compilation in VBA to differentiate between the 64bit and the 32bit version (using #If VBA7 Then ...
).
Is there also a build in constant similar to Application.Version
so that I can differentiate between Excel 2013/2010/2007/... etc. at compile time?
Also, is there a list of available existing compiler constants? So far I found VBA7
and Win64
(e.g. from this article) - but are there any other ones?
You can't do it, plain and simple. VBA code lives in an Excel workbook and there is no way, that I know, to compile that code outside of a workbook. The long and the short of it is: The users of your Excel programs must have Excel installed.
Conditional compilation is the process of selecting which code to compile and which code to not compile similar to the #if / #else / #endif in C and C++. Any statement that is not compiled in still must be syntactically correct.
Conditional Formatting in Excel VBA. We can apply conditional formatting. It can be found in the styles section of the Home tab. read more to a cell or range of cells in Excel.
From this link, you have the following constants:
VBA6
VBA7
Win64
Win32
Win16
Mac
Not to the version granularity questioned, but I had a need to separate Office 365/XL16- specific code from its predecessors. VBA7 is backwards compatible with VBA6, and VBA6 knows nothing of VBA7. We can use this to our advantage.
Sub testit()
#If VBA6 And VBA7 Then
Debug.Print "Cool!" 'XL16 vba code
#Else
Debug.Print "Yeah!" 'Not XL16 vba code
#End If
End Sub
XL14 and below evaluate #If as if true/false, XL16 as true/true. If it's just #If VBA7, XL14 attempts to compile the XL16 code. I don't know why, but that's how it tested.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With