Main Page



Visual Basic for Applications (VBA) is an implementation of Microsoft's event-driven programming language Visual Basic 6, which was discontinued in 2008, and its associated integrated development environment (IDE). Although Visual Basic is no longer supported or updated by Microsoft, the VBA programming language was upgraded in 2010 with the introduction of Visual Basic for Applications 7 in Microsoft Office applications.

Visual Basic for Applications enables building user-defined functions (UDFs), automating processes and accessing Windows API and other low-level functionality through dynamic-link libraries (DLLs). It supersedes and expands on the abilities of earlier application-specific macro programming languages such as Word's WordBASIC. It can be used to control many aspects of the host application, including manipulating user interface features, such as menus and toolbars, and working with custom user forms or dialog boxes.

As its name suggests, VBA is closely related to Visual Basic and uses the Visual Basic Runtime Library. However, VBA code normally can only run within a host application, rather than as a standalone program. VBA can, however, control one application from another using OLE Automation. For example, VBA can automatically create a Microsoft Word report from Microsoft Excel data that Excel collects automatically from polled sensors. VBA can use, but not create, ActiveX/COM DLLs, and later versions add support for class modules.

VBA is built into most Microsoft Office applications, including Office for Mac OS X (except version 2008), and other Microsoft applications, including Microsoft MapPoint and Microsoft Visio. VBA is also implemented, at least partially, in applications published by companies other than Microsoft, including ArcGIS, AutoCAD, CorelDraw, LibreOffice, Reflection, SolidWorks, and WordPerfect.

The Object Model Idea
Developers organize programming objects in a hierarchy, and that hierarchy is called the object model of the application.

The definition of an object is called a class, so you might see these two terms used interchangeably. Technically, a class is the description or template that is used to create, or instantiate, an object.

Once an object exists, you can manipulate it by setting its properties and calling its methods. If you think of the object as a noun, the properties are the adjectives that describe the noun and the methods are the verbs that animate the noun. Changing a property changes some quality of appearance or behavior of the object. Calling one of the object methods causes the object to perform some action.

Version history

 * VBA was first launched with MS Excel 5.0 in 1993. It became an instant success among developers to create corporate solutions using Excel. Inclusion of VBA with Microsoft Project, Access and Word replacing AccessBASIC and WordBASIC respectively made it more popular.
 * VBA 4.0 is the next famous release with a totally upgraded version compared to previous one. Released in 1996, it is written in C++ and became an object oriented language.
 * VBA 5.0 was launched in 1997 along with all of MS Office 97 products. The only exceptions for this was Outlook 97 which used VBScript to automate ● things.
 * The Year 1999 saw the launch of VBA 6.0, notably with support for COM add-ins in Office 2000. VBA 6.2 was released alongside Office 2000 SR-1.
 * VBA 6.3 was released after Office XP, VBA 6.4 followed Office 2003 and VBA 6.5 was released with Office 2007.
 * Office 2010 includes VBA 7.0. There are no new features in VBA 7 for developers compared to VBA 6.5 except for 64-bit support. However, after VBA 6.5/Office 2007, Microsoft stopped licensing VBA for other applications.
 * Office 2013 and Office 2016 include VBA 7.1.

= Documentation =

Text

 * Access Built-in Functions
 * '''MS Access Object Model
 * VBA Conceptual Topics
 * VBA Glossary
 * VBA Hacks
 * VBA Language Reference
 * VBE - Visual Basic Editor - A User's Guide to the Visual Basic Editor In Microsoft Office

Array Formulas
Use CTRL-SHIFT-ENTER when entering or editing array formulas. Excel supplies the braces.

Procedures
Access VBA Code Repository  (Built-in,User Defined,Windows API)

Word VBA Code Repository

Spreadsheets

 * Hohmann (Delta-V)
 * Hohmann (TOF)
 * Nearby Stars
 * Star Matrix

Show ASCII table
BEGIN { for (i=0; i<16; i++) { for (j=32+i; j<128; j+=16) { if (j == 32) { x = "SPC" } else if (j == 127) { x = "DEL" } else { x = sprintf("%c",j) } printf("%3d: %-5s",j,x) }      print "" } }
 * 1) Usage: awk -f showascii

Tally up a column of figures
case "$1" in [1-9]*) colnum="$1"; shift;;  *) echo "Usage: `basename $0` colnum [files]" 1>&2; exit 1;; esac awk '{sum += $col} END {print sum}' col=$colnum OFMT='%.2f' ${1+"$@"}
 * 1) ! /bin/sh

Use awk to list the thirty most-common words in a text file
{  nbytes += length($0) + 2 # +2 for CR/LF nfields += NF    $0 = tolower($0) for (i=1; i<=NF; i++) { arr[$i]++ } } END { show = (show == "") ? 30 : show width1 = length(show) PROCINFO["sorted_in"] = "@val_num_desc" for (i in arr) { if (width2 == 0) { width2 = length(arr[i]) } if (n++ >= show) { break } printf("%*d %*d %s\n",width1,n,width2,arr[i],i) }    printf("input: %d records, %d bytes, %d words of which %d are unique\n",NR,nbytes,nfields,length(arr)) exit(0) }
 * 1) Usage: awk -f wordfreq textfile.txt

Awk

 * Avg - Average two values in scientific notation
 * Bytes - Tally up bytes of all files in a directory
 * Dir - Print working directory file permissions, sizes, and names, formatted with awk
 * Lorentz Calculate the Lorentz factor for any velocity as a fraction of c (the speed of light)
 * ShowAscii - Show ASCII table
 * Tally - Tally up a column of figures.
 * Whatis - Get a one-line description for all the files in a directory, delete lines that have no description
 * Wordfreq - List the thirty most-common words in a text file

Bc

 * Factorial - Factorial function implemented by recursion.
 * Float - Convert a floating point number to binary
 * Sin-Cos - Print the sin and cos functions over the range -π to +π
 * Trig - Trigonometric functions

VIM COMMANDS
Because I am an 1337 h4x0r and don't want to use anything that you n00bs might be able to understand.

Wiki

 * MediaWiki Markup Language
 * Code Markup
 * Excel to Wiki Converter
 * Navigation Template
 * Barry (Talk)
 * Joel (Talk)