Microsoft Office 2000 Developer |
You can gain access to the Microsoft® Windows® API (or other outside DLLs) by declaring the external procedures within your VBA application. After you declare a procedure, you can use it like any other language feature in the product.
The most commonly used set of external procedures are those that make up Microsoft Windows itself. The Windows API contains thousands of functions, subs, types, and constants that you can declare and use in your projects. These procedures are written in the C language, however, so they must be declared before you can use them with VBA. The declarations for DLL procedures can become fairly complex. While you can translate these yourself, the easiest way to access the Windows API is by using the predefined declares included with the Office 2000 Developer WinAPI Viewer.
The file Win32api.txt, located in the ..\Microsoft Office\ODETools\V9 directory, contains declarations for many of the Windows API procedures commonly used in VBA. To use a function, type, or other feature from this file, simply copy it to your code module. You can view and copy procedures from Win32api.txt by using the API Viewer application or by loading the file in any text editor.
Note The Windows API contains a vast amount of code. To find reference information on the procedures and other details included in this API set, refer to the Win32 SDK, included on the MSDN™ Library CD.
For information about | See |
Using the WinAPI Viewer to view, copy, and paste declares, constants, and types easily into your code | Using the WinAPI Viewer Application |
Optimizing the WinAPI information for quicker and easier access in the WinAPI Viewer | Converting Text Files to Access Database Files |
For more information about using WinAPI in your code, see Chapter 10, "The Windows API and Other Dynamic-Link Libraries" in the Microsoft Office 2000/Visual Basic Programmer's Guide.