O'Reilly logo

Excel® 2007 VBA Programmer's Reference by Michael Alexander, Rob Bovey, Stephen Bullen, John Green

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 27. Programming with the Windows API

Visual Basic for Applications is a high-level language that provides you with a rich, powerful, yet quite simple set of functionality for controlling the Office suite of products, as well as many other applications. You are insulated — some would say protected — from the "mundane minutiae" of Windows programming that, say, a C++ programmer has to contend with.

The price you pay for this protection is an inability to investigate and control many elements of the Windows platform. You can, for example, use Application.International to read most of the Windows Regional Settings and read the screen dimensions from Application.UsableWidth and Application.UsableHeight, but that's about it. All the Windows-related items available to you are properties of the Application object and are listed in Appendix A.

The Windows platform includes a vast amount of low-level functionality that is not normally accessible from VBA, from identifying the system colors to creating a temporary file. Some of the functionality has been exposed in VBA, but only to a limited extent, such as creating and using an Internet connection (for example, you can open a page from the Internet using Workbooks.Open "<URL>", but you can't just download it to disk). There are also a number of other object libraries typically available on Windows computers that provide high-level, VBA-friendly access to the underlying Windows functionality. Examples of these are the Windows Scripting ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required