Chapter 14. 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 that many Access developers never require anything else.

However, when you start developing more and more complex applications in Access, you may find yourself needing to do things for which VBA does not have a built-in function. 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 because the API is inherently VBA-unfriendly, you must first understand what it is, and what special considerations you must take into account to use it from VBA.

This chapter explores what the Windows API is, and why you might want to use it. It describes the libraries that make up the API and how to link them into your application. Then you'll see how to declare API functions to use them with VBA and examine the differences between the data types used in APIs and those used in VBA, learning techniques and formulas to convert between them.

Finally, the chapter introduces the VBA LastDLLError method for dynamic-link ...

Get Access™ 2007 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.