Main Page



= VBA Code = This Wiki is a repository for VBA Code that works. Please refrain from posting code you have not tested. Non-functioning code frustrates amateur coders and discourages them from using this wiki.

Excel VBA Code Repository

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

Word VBA Code Repository

Documentation

 * Excel Built-in Functions
 * 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

Spreadsheets

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

Bash

 * Backup - Download a local copy of the entire vba.miraheze.org wiki.
 * Lowerit - Make all filenames in a directory lowercase
 * Mp3ToWav - Convert an mp3 to a wav file
 * PrintDirs - List all directories under the current working directory
 * '''Rot13 - Perform a rot13 conversion
 * StripBlanks - Build a new file minus any blank lines
 * StripWords - Make a new file from the individual words in another file, with one word per line.

LibreOffice

 * LibreSorter - Sorter procedure under LibreBasic

Wine

 * Excel97 - Excel97 under Wine

NT4 for Workstations

 * Excel97 - VBA 5.0

XP

 * Excel2003 - VBA 6.4
 * MoreUndo - RegEdit hack to raise the number of undo actions from a default of 16 to 64 undos.

Windows10

 * Office2019 - VBA 7.1

Wiki

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

About !
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.