ThreeWave 32-Bit And 64-Bit Versions Of Office

This page describes some issues related to 64-bit Excel.
ShortFadeBar

Introduction

With the release in Windows 7, 64-bit computing has seen tremendous growth in the number of computers that use the 64-bit version of Windows. Once only in the domain of high-end workstations, 64-bit Windows is installed on nearly every new computers, even low-end models.

SectionBreak

32 Or 64 Bits

Sixty-four and thiry-two bit refers to the size of the "chunks" of data that get moved around within the internals of the system. Older machines worked with chucks 32-bits in width. Sixty-four bit computers move data around in chunks 64-bits in width. This also affects the amount of memory a computer can handle. Thirty-two bit machines use 32-bit memory addresses, so they are limited to 4,294,967,296 or 4GB (and even less in Excel) addressable memory cells. Anything beyond 4GB was wasted in a 32 bit system. Sixty four bit machines allow you to access (in theory) 18,446,744,073,709,600,006 or 2^19, or 18 quadrillion memory cells. For the most part, you won't see or do anything if you upgrade to 64-bit Windows, but most applications will run faster and you can install much more memory for memory intensive tasks such as video editing. Programs that use a great deal of memory will see often tremendous speed increases.

On the other hand, the advantages of using a 64-bit system or application may be minimal. In some cases, the performance differences comes down to milliseconds, so you may not see any advantage.

To determine whether you have 32 or 64 bit Windows, open the Control Panel and then the System item. The "System Type" element will indicate whether your computer is capable of 64 bit Windows and whether 64 bit Windows is in fact installed. 64-Bit Office can be run only on 64-bit Windows computers. If you have 32-bit Windows, then you have 32-bit Office.

Determining What Version Of Office You Have

To determine whether you have 64-bit Office, go to the File Menu (Excel 2010 and later or the Office Button in 2007), and choose Help. That screen will indicate whether you have 64-bit or 32-bit Office, as shown in the image below:
64-bit Info Screen

Should you need to determine this at run time, you can use a function like

Public Function Is64Bit() As Boolean
#If VBA7 And Win64 Then
    Is64Bit = True
#Else
    Is64Bit = False
#End If
End Function

Be sure to include the # characters as shown.

SectionBreak

64-Bit Office

Office is now available in both 32-bit and 64-bit versions. If you have 64-bit Windows, you can use either 32-bit Office or 64-bit Office. If you are not in 64-bit Windows, you are limited to the 32-version of Office (i.e., a 32-bit system cannot run any 64-bit programs). The default installation version is 32-bit. If you choose to install 64-bit Windows, be aware that you must remove ALL 32-bit Office applications, even if you don't intend to upgrade a program to Office 64-bit. For example, suppose you have Office 32-bit and you want to install just 64-bit Excel. You would have to uninstall ALL 32-bit Office programs, not just Excel. For most users, this is not a problem. Both the 32-bit and the 64-bit versions of Office use the same file formats, you can move documents back and forth between Windows 32-bit and 64-bit freely without any conversions or compatibility packs. However, this requirement of removing previous versions of Office applications is terrible for developers, since it is impossible to run earlier versions for compatibility and user interface testing. I use 32-bit versions of all of the Office applications, going back to XP, for development and testing, and use a dedicated laptop to handle 64-bit testing.

Files created with 32-bit Excel on a Windows 64 bit are fully compatible with Excel 32-bit application on a Windows 32-bit machine. Similarly, files created in 32-bit Excel are compatible with Office 64-bit as long as those workbooks do not contain VBA code that contains Declare statements. Declare statements allow you to bypass VBA completely and call Windows functions directly. For use with both 32 and 64 bit machines, the declarations must be modified to use the declaration appropriate for that installation. For example, the GetTickCount is one of the simplest API functions: it merely gets the number of milliseconds the system has been running. The 32-bit declaration is shown below.

Public Declare Function GetTickCount Lib "kernel32" _ 
Alias "GetTickCount" () As Long

To make the function compatible with both 64-bit Excel, we need first to find out whether we are working in 64-bit Excel. We use conditional compilation to do this:

#If VBA7 And Win64 Then
    Public Declare PtrSafe Function GetTickCount _  
        Lib "kernel32" () As LongLong
#Else
    Public Declare Function GetTickCount _  
            Lib "kernel32" () As Long
#End If

The VBA7 compiler variable indicates whether we are in Excel 2007 or later, the first versions to support 64-bit versions. The WIN64 compiler version indicates whether we are in a 64-bit version of Excel. Contrary to what its name implies, WIN64 does not mean specifically that you are running Windows 64-bit. It indicates whether you are in a 64-bit application. For example, if you are running 32-bit Excel on Windows 64-bit, the VBA7 constant will be True and the WIN64 constant will be False. The PtrSafe declaration tells Excel that you have converted the Long variables which used to be used as pointers are now replaced with the LongPtr data type. PtrSafe is not defined in versions prior to 2007.

Note that LongLong is a 64-bit integer available only in 64-bit Excel. You would also have to convert all the Long variables to LongLong variables or LongPtr variables. For example,

#If VBA7 And Win64 Then
    Dim L As LongLong
#Else
    Dim L As Long
#End If
L = GetTickCount()

It should be noted from the end user's perspective, there is no difference between 32 and 64 bit versions of Excel. The 64-bit version does not contains any features not found in the 32 bit version.

SectionBreak

Determining Bitness At Run Time

Unfortunately, there is no simple Application property that specifies whether you are in 32-bit or 64-bit Excel. However, a simple procedure with conditional compilation will do this.

Function Is64BitExcel() As Boolean
#If VBA7 And WIN64 Then
    Is64BitExcel = True
Else
    Is64BitExcel = False
End If
End Function

This function will return True if the currently running version of Excel is a 64 bit verison, or False if the current running verison of Excel is 32-bit.

There are a number of additional considerations for porting code to 64 bit Excel and for allowing code to run cleanly in either 64 or 32 bits. See this Microsoft article and this Microsoft article for more information.

Note that most of the modules on this site that use a Declare statement have not been converted to 64-bit Excel, so any module that uses a Declare method won't work on 64-bit Excel. I am in the process of updating all my modules to 64-bit, but that is a daunting task given that I have several hundred modules to test and convert.

ShortFadeBar
LastUpdate This page last updated: 31-Dec-2011..

-->