CryptoSys Home > VBA declaration modules for 64-bit Office

VBA declaration modules for 64-bit Office


This page used to have downloads for separate declaration modules to use for 64-bit Microsoft Office. The necessary information is now all included in one file in the distributions.

We'll keep this page here for reference, especially for the explanation Why are some lines showing in red in my IDE?.

Product64-bit Office
module
Universal
module
CryptoSys PKIAll variants now in basCrPKI.bas as of v20.2.0[1]
CryptoSys APIAll variants now in basCryptoSys.bas as of v6.20.0[2]
FirmaSATAll variants now in basFirmaSAT.bas as of v10.0.0
SC14NAll variants now in basSc14n.bas as of v3.0.0
xmlsqAll variants now in basXmlsq.bas as of v1.0.0
Important notes for VBA users of CryptoSys PKI and CryptoSys API

[1] All necessary 32- and 64-bit declarations and all VBA wrapper functions for CryptoSys PKI are now included in the one file basCrPKI.bas. The old files basCrPKI64.bas, basCrPKI64_32.bas and basCrPKIWrappers.bas must not be used for version 20.2 and above.

[2] All necessary 32- and 64-bit declarations and all VBA wrapper functions for CryptoSys API are now included in the one file basCryptoSys.bas. The old files basCryptoSys64.bas, basCryptoSys64_32.bas and basCryptoSysWrappers.bas must not be used for version 6.20 and above.

VBA in 64-bit versions of Office

To use the VBA functions in your CryptoSys product with a 64-bit version of Microsoft Office you need to edit all the declaration statements as in this example:

- Public Declare Function API_Version Lib "diCryptoSys.dll" () As Long   ' Original 32-BIT
+ Public Declare PtrSafe Function API_Version Lib "diCryptoSys.dll" () As Long   ' New 64-BIT

That is, add the keyword PtrSafe between "Public Declare" and "Function". There are no other changes to make. This is done for you in the 64-bit Office modules above.

You do not need to use the Win64 constant with any of the modules for our products. You must not change any types to LongLong or LongPtr.

Universal modules for all variants

To use a "Universal" version use the the VBA7 conditional compilation constant. For example.

#If VBA7 Then 
  Public Declare PtrSafe Function API_Version Lib "diCryptoSys.dll" () As Long
#Else 
  Public Declare Function API_Version Lib "diCryptoSys.dll" () As Long
#End If	

The Universal module will work in any variant of Office, 32-bit and 64-bit, as well as the old Visual Basic 6 (VB6), but be aware that some lines may show red in your IDE [See Note 1].

Why are some lines showing in red in my IDE?

This may display one set of code in red in your IDE:

#If VBA7 Then
  Public Declare PtrSafe Function API_Version Lib "diCryptoSys.dll" () As Long
#Else 
  Public Declare Function API_Version Lib "diCryptoSys.dll" () As Long
#End If

but this will be ignored by the compiler when it runs. It just looks unsightly.

Note 1: In old Visual Basic 6.0, it helps to turn off the Auto Syntax Check. This will still highlight errors in red, it just won't give you that annoying message box.
Tools > Options > Editor

Turn off Auto Syntax Check

More information

This page last updated 15 August 2025