Tag Info

Visual Basic for Applications (VBA) is an event-driven programming language 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. It is now used for the entire Office suite and over 200 non-Office hosts.

Visual Basic for Applications (VBA) is an event-driven programming language first introduced by Microsoft in 1993 designed 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.

The last full version, VBA 6, was shipped in 1998 and includes a myriad of licensed hosts, among them: Office 2000 - 2010, AutoCAD, PI Processbook, and the stand-alone Visual Basic 6.0. VBA 6 code will run equally well on any host, though the underlying objects native to each host will vary. Though still built into Microsoft Office applications, VBA ceased to be an integral of part of Microsoft's development platform when Visual Basic .NET shipped with the first version of the .NET framework in 2002.

VBA has only been slightly updated since, only including new features to allow it to remain compatible with x64 versions of Windows and Office. VBA 7 was released in 2010 to address the new 64-bit version of Microsoft Office which shipped in 2010. There are several important changes made to VBA 7 that make it different from VBA 6, namely compatibility with both 32 and 64-bit versions of Office. Applications using VBA 7 must address both backwards compabitility and 64-bit-safe issues.

It was removed from Office for Mac 2008, however Microsoft returned VBA to Office 2011. Microsoft has continually been questioned about whether or not VBA will be removed altogether from Office and has repeatedly replied "no".

VBA inherits much of its syntax from the BASIC programming language, where language features tend to be explicitly expressed in words (e.g. If ... Then ... End If, Function ... End Function). It also has many object-oriented features, such as classes and interfaces, and even has some dynamic features, such as Variant. Below is a simple subroutine which generates a message box and prints a message to the Immediate window:

Public Sub HelloWorld()
Dim message As String
message = "Hello World"
MsgBox message
Debug.Print "I just made a message box that says """ & message & """!"
End Sub


Beginner Resources