I am developing some VBA code using VBA 7.1 with excel 2016 as part of a larger enterprise application (not primarily in excel). The macros are run from a C# application and used to export data in the form of spreadsheets. I am looking for a good guide as to what versions of excel these macros will run properly on, and where I can look for changes that could potentially cause my code to break. I developed it using excel 2016, how backwards compatible will this be?
I would like to make it compatible as far back as the 2010 excel version if possible.
If you need compatibility with VBA6 and VBA7, this is a good example how to achieve it through compiler constants:
Option Explicit
#If VBA6 Then
Sub RunTheApp()
Debug.Print "VBA6"
End Sub
#ElseIf VBA7 Then
Sub RunTheApp()
Debug.Print "VBA7"
End Sub
#Else
Sub RunTheApp()
Debug.Print "You cannot come here from TestMe()"
End Sub
#End If
Sub TestMe()
RunTheApp
End Sub
Once you try to run the TestMe
module, it will print VBA6
or VBA7
, depending on your system.
In general, VBA7 has compability for 64bit environment. Here is the MSDN article for the differences between these two - Compatibility between the 32-bit and 64-bit Versions of Office 2010 It is a good idea to read it, if you are using external functions that are embedded in dynamic linked libraries.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.