This version of VBA was introduced to accommodate some new features when running 64-bit Office.
Support for both 32 bit and 64 bit
links - msdn.microsoft.com/en-us/library/ee691831(loband).aspx#odc_office2010_Compatibility32bit64bit_IntroducingVBA7CodeBase
link - docs.microsoft.com/en-us/previous-versions/office/developer/officetalk2010/ff700513(v=office.11)
LongLong Data Type
Introduction of a new datatype called LongLong This is an 8 bytes (64 bit) signed integer that contains values between -9,223,372,036,854,775,808 and 9,223,372,036,854,775,807
This is only available in 64 bit installations Excel only provides 15 digits of precision so a number this large cannot be stored in an Excel cell without loss of precision
There is a new vartype constant - vbLongLong
This is an 8-byte data type which is available only in 64-bit versions of Office 2010. You can assign numeric values but not numeric types (to avoid truncation).
LongLong type-declaration character (^) - Explicitly declares a literal value as a LongLong. Required to declare a LongLong literal that is larger than the maximum Long value (otherwise it will get implicitly converted to double).
vartype constant vbLongLong
To accompany this new datatypes there is also a new conversion function CLngLng
There is also a new DefType statement of DefLngLng
The corresponding type declaration character is ^ ( to avoid any confusion with the exponentiation operator, always put a space before the caret when you want to use the exponentiation operator )
LongPtr Data Type
Introduction of a new datatype called LongPtr.
This datatype becomes a Long on a 32 bit installation and a LongLong on a 64 bit installation
This is the recommended way of declaring a pointer or a handle for new code but also for legacy code if it has to run in the 64-bit version of Office 2010.
It is only supported in the VBA 7 runtime on 32-bit and 64-bit. Note that you can assign numeric values to it but not numeric types.
The only things that require LongPtr are function arguments or return values that represent addresses in memory.
There is also a new conversion function CLngPtr.
There is also a new DefType statement of DefLngPtr.
Any code that uses LongPtr will work on both 32 bit and 64 bit
VBA7 and Win64 Compiler Constant
Two new compiler constants have been introduced to allow code to work across both 32 bit and 64 bit office.
The Win64 constant is true if you are in a 64 bit version of office The Win32 constants is also true for 64 bit office The VBA7 constant is true for Office 2010 or later #If VBA7 And Win64 Then #Else #End If
To write code that can work in both new and older versions of Office you can use a combination of the new VBA7 and Win64 conditional Compiler Constants.
The VBA7 conditional compiler constant is used to determine if code is running in version 7 of the VB editor (the VBA version that ships in Office 2010).
The WIN64 conditional compilation constant is used to determine which version (32-bit or 64-bit) of Office is running.
#If VBA7 then
' Code is running in the new VBA7 editor
#If Win64 then
' Code is running in 64-bit version of Microsoft Office
' Code is running in 32-bit version of Microsoft Office
' Code is running in VBA version 6 or earlier
When declaring an API you must acknowledge this fact by adding the PtrSafe keyword to the API declaration.
When declaring an API you must include the PtrSafe attribute to enable you to use this Declare statement on either 32-bit or 64-bit systems.
The PtrSafe attribute is optional on the 32-bit version of Office.
When running 32 Bit Office a pointer must be a 32 bit variable
When running 64 Bit Office a pointer must be a 64 bit variable.
Any code that declares a variable as LongPtr can be successfully passed on both 32 bit and 64 bit office.
Public Declare PtrSafe Function GetTickCount Lib "kernel32" () As LongPtr
Variant converter. Returns a LongPtr on 64-bit versions, and a Long on 32-bit versions (4 bytes).
Object converter. Returns a LongPtr on 64-bit versions, and a Long on 32-bit versions (4 bytes).
String converter. Returns a LongPtr on 64-bit versions, and a Long on 32-bit versions (4 bytes).
Sets the default data type for a range of variables as LongPtr.
Sets the default data type for a range of variables as LongLong.
Microsoft Office Code Compatibility Inspector Add-in
Tool you can use with Excel, Word, PowerPoint 2010 and Visual Studio 2008 to troubleshoot/resolve issues with your VBA macros.
link - technet.microsoft.com/en-us/library/ee833946(office.14).aspx
A 64 Bit Office processes cannot load 32-Bit binaries.
Existing 32-bit ActiveX controls, both third-party and Microsoft-supplied, are not compatible with 64-bit Office.
This includes the common controls of MSComCtl (TabStrip, Toolbar, StatusBar, ProgressBar, TreeView, ListViews, ImageList, Slider, ImageComboBox) and the controls of MSComCt2 (Animation, UpDown, MonthView, DateTimePicker, FlatScrollBar)
© 2021 Better Solutions Limited. All Rights Reserved. © 2021 Better Solutions Limited TopPrevNext