Visual Basic for Applications (VBA) is an event-driven, object-oriented programming language for writing macros, used for the MS Office suite as well as other applications. VBA is not equivalent to VBA6, VBA7, VB.NET, or VBS. If your question is specifically about programming any MS Office application, also use the appropriate tag: [excel], [ms-access], [ms-word], [outlook], [powerpoint] or [ms-project].
Visual Basic for Applications (VBA) is an event-driven programming language which was first introduced by Microsoft in 1993 to give Excel 5.0 a more robust object-oriented language for writing macros and automating the use of Excel. The language and its runtime quickly matured and began being used in products beyond Microsoft Office applications.
Differences between VBA 6.0 and VBA 7.0?
There's not a whole lot that has changed between VBA6 and VBA7. VBA7 was introduced to support 64-bit versions of both Office and Windows (see below on what those differences are). Here are the key changes:
64-bit support, primarily for API calls. This is both used to make your code work with your OS/Office version as well as others' (i.e. someone on Office 2003/WinXP)
If you are on a 64-bit version of Windows, but are on a 32-bit version of Office, you can declare API calls like below. .
#If Win64 Then Declare PtrSafe Function GetTickCount64 Lib "kernel32"() As LongLong #Else Declare PtrSafe Function GetTickCount Lib "kernel32" () As Long #End If
If you are on a 64-bit version of Windows, and are on a 64-bit version of Office, you can declare API calls like: .
#If VBA7 Then Declare PtrSafe Function FindWindow Lib "user32" Alias "FindWindowA" ( _ ByVal lpClassName As String, _ ByVal lpWindowName As String) As LongPtr #Else Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal _ lpClassName As String, ByVal lpWindowName As String) As Long #End If
To support this, there are:
Three new keywords (2 data types and 1 modifier): LongPtr, LongLong and PtrSafe
One new function: CLngLng() (i.e. Int64)
The new compilation constants as used above:
VBA7
andWin64
Reference