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 programmati-cally 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 within VB, VBA can control the VB Printer object.

What Can You Do with VBA? 7

Customizing and Creating Applications with VBA

Off-the-shelf—or "shrink-wrapped"—software products don't always provide the specialized features most corporate and many private users need, which means that some kind of customization is often needed to create the desired solution. Software vendors include features within their products that will appeal to as large an audience as possible. They quite rightly have to balance the cost of development with the potential extra sales for any new feature they add to their product. There is such an infinite range of different and unique business problems that it would be impossible for any off-the-shelf package to be versatile enough to fulfill every need.

Let's say you need an application that links to the company's main database and presents data in such a way that managers can readily understand and work with it, create charts from it, reformat it, etc. You could either spend the next 12 months developing and debugging your very own spreadsheet application, or you could supply a custom application written with VBA using Excel as the host. This applies, of course, not only to Excel, but to the other applications in Microsoft Office as well, which means that as a developer, you can also program interoperability between all the applications in the Microsoft Office suite.

The traditional home of VBA has been in Microsoft products. However, since Microsoft has now stamped VBA's passport by licensing it to other major software vendors, you will find VBA venturing further afield into territory that was once off limits. VBA skills will become more and more in demand as a wider range of software becomes VBA-enabled. This also means that for the first time, developers across a wide range of products have a common programming interface.

Of course, a software developer can always start from scratch to create a solution to a business problem, and the most popular tool for creating business applications is Visual Basic. A mark of Visual Basic's maturity is that for the first time, Microsoft's own developers have used Visual Basic to write parts of the Visual Studio 6 development suite. The most sophisticated business solutions using the latest technologies can be created with Visual Basic, and corporations, large and small, around the world are now looking to Visual Basic to provide mission critical enterprise-wide applications. The speed and relative ease with which a Visual Basic application can be created and maintained results in major cost savings for corporations. When you add to this the ease with which a Visual Basic application can be ported to a web environment, you can see why Visual Basic is the world's most popular RAD tool.

Was this article helpful?

0 0

Post a comment