1.3. What Can You Do with VBA?

VBA contains all the functions and statements necessary to create robust Windows applications, whether this is done using Visual Basic or a host application. The tasks you can perform with VBA include (but are not limited to):

  • Creating instances of OLE (ActiveX) objects within your code

  • Creating classes (reusable custom software objects)

  • Linking to ODBC databases like Access and SQL Server

  • Integrating with the messaging API (MAPI) to create Exchange/Mail applications

  • Integrating with Internet and intranet solutions

  • Creating custom dialog boxes and forms

  • Storing and retrieving data from the Windows registry

  • Detecting and handling errors

  • Incorporating ActiveX controls into the application interface

  • Passing data between VBA-enabled applications with a minimum of programming and fuss

  • Driving a second VBA-enabled application from within a first VBA-enabled application

  • Controlling the Office applications; in theory, 100% of the functionality of Office products is exposed as objects/properties/methods, which means that, with occasional exceptions, there isn't anything you can't do programmatically that you can do from the application's interface.

  • Automating anything that can be done from the keyboard, mouse, or menus

There is also one thing you can't do directly with the VBA language: you can't output to a printer. So how do you print from a VBA application? When hosted in an application, VBA can control the application's own printing functionality; when used ...

Get VB & VBA in a Nutshell: The Language now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.