32-bit vs 64-bit - Your Questions Answered
4 stars based on
32 reviews
For customers working with 2GB or more of data, Microsoft Office is now available in a bit version. This article discusses issues around the compatibility of the bit version with the new bit version and legacy bit Office applications and their solutions. Introducing the bit and bit Versions of Microsoft Office Comparing Bit Apple application support 32 bit and 64 bit both install base to Bit Systems. Application Programming Interface Compatibility. Using Conditional Compilation Attributes.
The Microsoft Office system is available in both bit and bit versions. The bit version enables you to work with much larger sets of data. This need is especially true when working with large numbers in Microsoft Excel It is important to note that the changes addressed in this article apply only to the bit version of Microsoft Office Using the bit version of Office enables you to use solutions built in previous versions of Microsoft Office without modification.
In a default installation of Officethe bit version is installed, even on bit systems. You must explicitly select the Office bit version installation option. Additionally, you must update address pointers and apple application support 32 bit and 64 bit both install base window handles in user-defined types that are used by these statements.
This is discussed in more detail in this article as well as compatibility issues between the bit and bit versions of Office and suggested solutions. Applications built with the bit version of Office can reference larger address spaces, and therefore provide the opportunity to use more physical memory than ever, potentially reducing the overhead spent moving data in and out of physical memory.
In addition to referring to specific locations also known as pointers in physical memory that an application uses to store data or to store programming instructions, you can also use addresses to reference display window identifiers known as handles. Depending on whether you are using a bit or bit system determines the size in bytes of the pointer or handle.
There are two fundamental issues when you run existing solutions with the bit version of Office Native bit processes in Office cannot load bit binaries. This is expected to be a common issue when you have existing Microsoft ActiveX controls and existing add-ins. VBA previously did not have a pointer data type and because of this, developers used bit variables to store pointers and handles. These variables now truncate bit values returned by API calls when using Declare statements.
VBA 7 exists for both the bit and bit versions of Office It provides two conditional compilation constants: The Win64 constant is used to test whether code is running as bit or as bit. Both of these compilation constants are demonstrated later in this article. With certain exceptions shown elsewhere in this article, the macros in a document this also includes workbook and presentations that have worked by using the bit version of that application will work when the document is loaded in the bit version of the same application.
Existing bit ActiveX controls, both third-party and Microsoft-supplied, are not compatible with the bit version of Office These controls were installed by previous versions of Microsoft Office and are installed by bit Office An alternative must be found for existing Microsoft Office VBA solutions that utilize these controls when the code is migrated to bit Office The combination of VBA and type libraries gives you lots of functionality to create Microsoft Office applications.
In these scenarios, your best option is to use one of the external functions that are embedded in dynamic linked library DLL files. Microsoft provides a Win32API. However, these statements are for bit systems and must be converted to bit by using the information discussed later in this article.
Existing Declare statements will not compile in bit VBA until they have been marked as safe for bit by using the PtrSafe attribute. Declare statements resemble one of the following, depending whether you are calling a apple application support 32 bit and 64 bit both install base which has no return value or a function which does have a return value.
The SubName function or FunctionName function is replaced by the actual name of the procedure in the DLL file and represents the name that is used when the procedure is called from VBA code.
You can also specify an AliasName argument for the name of the procedure, if desired. The name of the DLL apple application support 32 bit and 64 bit both install base that contains the procedure being called follows the Lib keyword.
And finally, the argument list contains the parameters and the data types that must be passed to the procedure. The following Declare statement opens a subkey in the Windows registry and replaces its value. This is because HKEY is defined as a pointer, whose size reflects the memory size of the platform that the code is compiled in. In previous versions of VBA, there was no specific pointer data type so the Long data type was used. And because the Long data type is always bits, this breaks when used on a system with bit memory because the upper bits may be truncated or may overwrite other memory addresses.
Either of these situations can result in unpredictable behavior or system crashes. To resolve this, VBA now contains a true pointer data type: This new data type enables you to write the original Declare statement correctly as:.
This data type and the new PtrSafe attribute enable you to use this Declare statement on either bit or bit systems.
Without this attribute, using the Declare statement in a bit system will result in a compile-time error. Note that the PtrSafe attribute is optional on the bit version of Office This enables existing Declare statements to work as they always have.
The following table provides more information on the new qualifier and data type already discussed as well as another data type, two conversion operators, and three functions. Indicates that the Declare statement is compatible with bits. This attribute is mandatory on bit systems. A variable data type which is a 4-bytes data type on bit versions and an 8-byte data type on bit versions of Office 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 bit version of Office It is only supported in the VBA 7 runtime on bit and bit.
Note that you can assign numeric values to it but not numeric types. This is an 8-byte data type which is available only in bit versions of Office You can assign numeric values but not numeric types to avoid truncation.
Returns a LongPtr on bit versions, and a Long on bit versions 4 bytes. The follow example shows how to apple application support 32 bit and 64 bit both install base some of these items in a Declare statement. Note that Declare statements without the PtrSafe attribute are assumed not to be compatible with the bit version of Office As stated earlier, there are two new conditional compilation constants: To ensure backward compatibility with previous versions of Microsoft Office, you use the VBA7 constant this is the more typical case to prevent bit code from being used apple application support 32 bit and 64 bit both install base the earlier version of Microsoft Office.
For code that is different between the bit version and the bit version, such as calling a math API which uses LongLong for its bit version and Long for its bit version, you use the Win64 constant. The following code demonstrates the use of these two constants. To summarize, if you write bit code and intend to use it in previous versions of Microsoft Office, you will want to use the VBA7 conditional compilation constant.
However, if you write bit code in Officethat code works as is in previous versions of Microsoft Office without the need for the compilation constant.
If you want to ensure that you are using bit statements for bit versions and bit statements for bit versions, your best option is to use the Win64 conditional compilation constant. The following code is an example of legacy VBA code that needs to be apple application support 32 bit and 64 bit both install base. Notice the data types in the legacy code that are updated to use LongPtr because they refer to handles or pointers.
The following are frequently asked questions that relate to the bit and bit versions of Microsoft Office. This is more a matter of which host application Excel, Word, and so forth you are using. For example, Excel is able to handle much larger worksheets with the bit version of Microsoft Office. Handles and pointers need to be converted to LongPtr. As an example, the documentation for RegOpenKeyA provides the following signature:.
You should use these functions to retrieve pointers to strings, variables and objects, respectively. On the bit version of Microsoft Office, these functions will return a bit LongPtrwhich can be passed to Declare statements. The use of these functions has not changed from previous versions of VBA. The only difference is that they now return a LongPtr. The addition of a bit version of Office enables you to move more data around for increased capability.
When writing bit code, you can use the bit version of Microsoft Office without any changes. However, when you write bit code, you should ensure that your code contains specific keywords and conditional compilation constants to ensure that the code is backward compatible with earlier version of Microsoft Office, and that the correct code is being executed if you mix bit and bit code.
For more information about Declare statements, see the following resources:. Anatomy of a Declare Statement. This site uses cookies for analytics, personalized content and ads. By continuing to browse this site, you agree to this use.
Office Office Technical Articles. Compatibility Between the bit and bit Versions of Office Customizing Context Menus in Office Apple application support 32 bit and 64 bit both install base the Office Backstage View for Developers. Interoperability and Implementation Notes. Introduction to the Office Backstage View for Developers. Office Mobile Service Guidelines Part 1 of 3. Office Mobile Service Guidelines Part 2 of 3. Office Mobile Service Guidelines Part 3 of 3.
Ribbon Extensibility in Office