Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are the differences between VBA 6.0 and VBA 7.0?

I noticed that Office 2010 comes with Visual Basic for Applications 7.0. However I can't seem to find much documentation on what changes were made. Does anyone have a summary of the changes, or any resources describing the differences?

like image 480
romandas Avatar asked Jun 18 '10 18:06

romandas


People also ask

What VBA 7?

The Vba7 conditional compiler constant is used to determine if code is running in version 7 of the VB editor (the VBA version that ships in Office 2010). The Win64 conditional compiler constant is used to determine which version (32-bit or 64-bit) of Office is running.

What is the difference between Visual Basic and VBA?

VBA stands for Visual Basic For Applications and its a Visual Basic implementation intended to be used in the Office Suite. The difference between them is that VBA is embedded inside Office documents (its an Office feature). VB is the ide/language for developing applications.

Is Microsoft getting rid of VBA?

Microsoft is finally planning to block Visual Basic for Applications (VBA) macros by default in a variety of Office apps. The change will apply to Office files that are downloaded from the internet and include macros, so Office users will no longer be able to enable certain content with a simple click of a button.

Is VBA the same as VB Net?

No, the only similarity between VBA and VB.NET is the similar-looking syntax. VBA is similar to Visual Basic 6, which is obsolete since about 1997 (?), so VBA is not a very modern language. VB.NET is a modern language, having the same capabilities as C#, but the syntax is terrible, so I personally prefer C#.


2 Answers

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:

  1. 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
  2. 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 and Win64

like image 72
Todd Main Avatar answered Sep 20 '22 11:09

Todd Main


This piece on MSDN has more on the changes in VBA 7 for Office 2010:

http://msdn.microsoft.com/en-us/library/ee691831(loband).aspx#odc_office2010_Compatibility32bit64bit_IntroducingVBA7CodeBase

like image 33
Lunatik Avatar answered Sep 20 '22 11:09

Lunatik