2.4 Procedures

A procedure is the unit of algorithmic functionality within a VBA Environment. Most procedures are defined using the VBA language, but the VBA Environment also contains standard procedures defined by this specification and can contain procedures provided in an implementation defined manner by the host application or imported from externally defined libraries. A procedure is identified by a procedure name that is part of its declaration.

VBA also includes the concept of a property, a set of identically named procedures defined in the same module (section 4.2). Elements of such a set of procedures can then be accessed by referencing the property name directly as if it was a variable name (section 2.3). The specific procedure from the set that to be invoked is determined by the context in which the property name is referenced.

A VBA Environment is not restricted to executing a single program that starts with a call to a main procedure and then continues uninterrupted to its completion. Instead, VBA provides a reactive environment of variables, procedures, and objects. The host application initiates a computation by calling procedures within its hosted VBA Environment. Such a procedure, after possibly calling other procedures, eventually returns control to the host application. However, a VBA Environment retains its state (including the content of most variables and objects) after such a VBA Environment initiated call returns to the host application. The host application can subsequently call the same or other procedures within that VBA Environment. In addition to explicit VBA Environment initiated calls, VBA procedures can be called in response to events (section 2.5) associated with host application-provided objects.