An Introduction To

ou use the Visual Basic for Applications (VBA) programming language to create all macros within Excel. Although most people use VBA for macro development, VBA is actually much more powerful than just a macro language.


A member of the Visual Basic (VB) family, VBA sits between Visual Basic and VBScript as far as overall functionality. Amazingly enough, VBA actually provides a large portion of the language elements that VB uses, including forms, controls, objects, modules, and dataaccess technologies. The code for the three languages resemble each other so much that you may find it difficult to differentiate between VB, VBA, and VBScript when looking at a line of code. One of the big differences between VB and VBA programs is the fact that VBA code runs within the host environment, which means that VBA code for Excel runs within Excel. Also, VBA code is interpreted as it runs, which means that each line converts to machine code prior to execution. VB code, on the other hand, compiles into an executable file that runs independent of any other applications. Therefore, programmers consider VBA an interpreted language because as it runs, the environment in which it runs interprets the code to determine what to do next. Microsoft Office XP provides VBA in all its applications. Many non-Microsoft applications also use VBA, as the platform for developing code that interfaces with the object model for the specific application. By interfacing with the application object model, VBA can manipulate different objects directly, such as changing the value in a cell within Excel. You interface with the particular application object mode by writing macros, but you can also use VBA to develop applications that interface with the corresponding Microsoft application. Each Microsoft Office XP application has its own object model for interfacing with the program functionality. See Chapter 4 for more on the Excel object model.


To call VBA a macro language, severely limits your understanding of its overall capability. VBA actually has many features lacking in other macro languages. Historically strong in their ability to capture a series of keystrokes to repeat simple tasks, many macro languages types of macros lack the capability of creating conditional statements or conditionally repeating a series of steps.

Because VBA replaced XLM, the original macro language of Excel, developers commonly refer to it as a macro language. Although the book uses VBA only to work with Excel macro concepts, you should know that you have the option of using it for application development. Such application development, however, is limited to the Microsoft Office program environment, in which VBA runs.


The remaining chapters in this book deal with the basics of the VBA language in respect to Excel macros and how you can use VBA to add complex functionality to a macro. To perform the tasks, you need to grasp the common VBA terminology that this book utilizes.

0 0

Post a comment