VBA event handlers

An event handler that executes VBA functions is one of the four types of event handlers that you can define for INVOICES.

VBA functions can access information from the current context. For example, when INVOICES is interpreting a particular invoice, a function can access individual fields on the invoice, the invoices itself, and some information from the invoice profile. Other invoices in the database are inaccessible.

When a VBA function is called, the block of code associated with the event handler is compiled and the function is called. VBA functions can call other VBA functions and can fire events of their own.

The internal VBA engine provides many features that can be used to customize INVOICES. In addition to traditional language constructs, you can create dialogs, manipulate files, communicate using ActiveX automation, call functions in DLLs, and call several of the functions provided by the Win32 API.

What you cannot use the internal VBA engine for is advanced window handling, socket programming (Internet), and database communication (such as ODBC). For database communication, consider using an external event server object, a plug-in, or calling DLL functions. You can also let the event handlers communicate with ActiveX objects that implement the required functionality.

Warning

INVOICES' internal VBA engine is recommended only for simple debugging or status messages. We strongly advise against using the VBA engine for production customizations. For those, use COM plug-ins.

VBA functions access data through INVOICES' Application object (OLE API), or one of its six Application objects (COM API). The Application object provides access to invoice profiles, invoice definitions, and more information such as invoices and job descriptions. From an invoice object you can access the fields contained in an invoice. There are many types of objects that you can access from the application object.

You can pass parameters to a VBA function using ordinary VBA function syntax. To access INVOICES data, you must obtain an object reference to INVOICES via ActiveX automation.

You can also pass simple strings from one event handler to another.

VBA and DLL event handlers: Overview

Defining event handlers