ptrSafe keyword
The ptrSafe
keyword makes sure that a can be safely run in a 64 bit-environment.
64-bit versions of Office (or the VBA runtime)
require a
declare
statement to be decorated with
ptrSafe
.
I
believe (but would like to have this confirmed or refuted) that the idea of
ptrSafe
is to force a developer to think about the
data types that need to be adjusted when moving from 32 bit to 64 bit. By declaring a function with
ptrSafe
, the developer explicitly states that the necessary changes to
longLong
and
longPtr
have been performed.
#if vba7 then
declare ptrsafe sub …
#else
declare sub …
#endif