API stands for Application Programming Interface
API's for VBA imply a set of methods that allow direct interaction with the operating system
System calls can be made by executing procedures defined in DLL files
Common operating environment library files (DLL's):
Dynamic Link Library | Description |
---|---|
Advapi32.dll | Advanced services library for APIs including many security and Registry calls |
Comdlg32.dll | Common dialog API library |
Gdi32.dll | Graphics Device Interface API library |
Kernel32.dll | Core Windows 32-bit base API support |
Lz32.dll | 32-bit compression routines |
Mpr.dll | Multiple Provider Router library |
Netapi32.dll | 32-bit Network API library |
Shell32.dll | 32-bit Shell API library |
User32.dll | Library for user interface routines |
Version.dll | Version library |
Winmm.dll | Windows multimedia library |
Winspool.drv | Print spooler interface that contains the print spooler API calls |
New arguments used for the 64 system:
Type | Item | Description |
---|---|---|
Qualifier | PtrSafe | Indicates that the Declare statement is compatible with 64-bits. This attribute is mandatory on 64-bit systems |
Data Type | LongPtr | A variable data type which is a 4-bytes data type on 32-bit versions and an 8-byte data type on 64-bit versions of Office 2010. 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 |
Data Type | LongLong | 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) |
Conversion | Operator | CLngPtr Converts a simple expression to a LongPtr data type |
Conversion | Operator | CLngLng Converts a simple expression to a LongLong data type |
Function | VarPtr | Variant converter. Returns a LongPtr on 64-bit versions, and a Long on 32-bit (4 bytes) |
Function | ObjPtr | Object converter. Returns a LongPtr on 64-bit versions, and a Long on 32-bit (4 bytes) |
Function | StrPtr | String converter. Returns a LongPtr on 64-bit versions, and a Long on 32-bit (4 bytes) |
Full reference of call signatures:
Win32api32.txt for Visual Basic 5.0 (old API declarations, last reviewed Mar 2005, Microsoft)
Win32API_PtrSafe with 64-bit Support (Office 2010, Microsoft)