Visual Basic for Applications version 7.1, 32Bit and 64 Bit


The next version of zenon will be available in 32 and 64 bit. Therefore the included Visual Basic for Applications package will be upgraded from the 6.5 (32Bit) to 7.1 (32 and 64Bit). When using the 32Bit version of zenon none of the existing code needs to be modified, workspace and runtime projects can stay the way they are. But to take full advantage of the available memory and hardware the 64 Bit version is obviously the better choice.


When using the 64 Bit version of zenon, VBA 7.1 will also run in 64 Bit mode. To differentiate between the 32 and 64 Bit version quite a few keywords, defines and declarations have been introduced to VBA.

Any existing API declarations have to be modified in order to be used in 64 Bit mode. For example the API-function “FindWindow” (which can be used to find a window by use of its class name and window name) used to be defined like this in a 32Bit VBA project:

Private DeclareFunction FindWindow Lib "USER32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long

Whereas the 64 Bit version of this declaration needs to be:

Private Declare PtrSafe Function FindWindow
Lib "USER32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As LongPtr

NOTE: The 64 Bit declaration will work for the 32 Bit version mode of VBA 7.1 as well.
Since Microsoft currently does not include a 64Bit version of the “Microsoft Common Controls”, objects from this package cannot be used in the 64 Bit mode. This  package includes the CommonDialog-Controls often used for “File-Open” and “Color-Picking”-Dialogs.

Additions and mixing

Microsoft introduced two new conditional compilation constants: “VBA7” and “Win64”. The VBA7 constant can be used to determine whether the project is running under VBA7 or on an older version. This constant is useful for backwards compatibility, and prevents the requirement for separate
“pre-7” and “7”-versions of custom created classes.

#If VBA7 Then
'Use VBA7 functionality
'Stick to old VBA solution
#End If

The Win64 constant enables a separation between the 32 and 64 bit version of VBA and can be used to ensure that code is only executed when VBA runs in the correct mode.

Tags: ,

Leave a Reply