Chapter 13. Extending VBA with APIs

Microsoft Visual Basic for Applications (VBA) is a full-featured software development language that offers a vast array of built-in functions, so much so that many Access developers never require anything else.

However, when you start developing more and more complex applications in Access, you may eventually find yourself needing to do things that VBA does not have a built-in function for. Moreover, you'll sometimes need to do things that VBA simply can't do. That's not to say that VBA is incomplete, but, like every other programming language, it does not include every function you're ever likely to need. A line has to be drawn somewhere, and Microsoft drew that line at the functions provided by the API.

The Windows operating system provides a large library of functions that you can access using VBA to extend what you're able to do in your applications. But since the API is inherently VBA-unfriendly, you must first understand what it is, and what special considerations you must take account of in order to use it from VBA.

This chapter explains what the Windows API is, and why you might want to use it. We'll describe the libraries that make up the API and how to link them in to your application. We'll then show you how to declare API functions to use them with VBA. Then we'll describe the differences between the data types used in APIs, those used in VBA, and provide the techniques and formulas to convert between them.

We'll finish off this ...

Get Access 2003 VBA Programmer's Reference 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.