daily notes[68]
文章目录
- vba
- references
vba
-
Office VBA is an event-driven language that can automate most operations in Excel, such as those involving the mouse, keyboard, dialogs, and automatic execution.
-
Microsoft Visual Basic for Applications (VBA) is provided with Microsoft Office as a Visual Basic language. Its version has been upgraded to 64-bit starting from Office 2019 and Microsoft 365.
-
if your Office version is below 2019, you should use the 32-bit VBA because the 64-bit version running on that Office may cause various errors such as memory overflow, data truncation, and aberrant results when the code runs.
-
To maintain compatibility between 32-bit and 64-bit environments, several features were added to VBA. The primary ones are as follows:
-
LongPtr: This variable type is interpreted as a Long when running in 32-bit mode and as a LongLong in 64-bit mode. It is used for pointers and handles.
-
LongLong: The LongLong data type is a signed 64-bit integer available only in the 64-bit version of Office. Use LongLong for 64-bit integers. Conversion functions must be used to explicitly assign a LongLong to smaller integer types (including LongPtr on 64-bit platforms). Implicit conversion of LongLong to smaller integers is not permitted.
-
PtrSafe: The PtrSafe keyword asserts that a Declare statement can run safely in the 64-bit version of Office.
All Declare statements must include the PtrSafe keyword to run in the 64-bit version of Office, which implies that adding PtrSafe only signifies the statement is explicitly targeted for 64-bit.
references
- https://learn.microsoft.com/