Chapter 2. Getting Acquainted with Visual Basic for Applications

Introduction

I started using Visual Basic in the early 1990s, way back in the days of DOS and Windows 3.1. At the time, I was not all that impressed with Visual Basic and preferred Visual C and a few Borland products over Visual Basic. I still prefer C/C++ for most of the commercial applications I develop for clients; however, when I need to perform quick calculations for my own research or when a client needs something done quickly, I do now turn to Visual Basic for Applications (VBA).

When I first used Visual Basic, I saw no advantage over the other languages I was using at the time. All that changed, however, when Microsoft integrated Visual Basic with its Office suite of applications. This opened the door to greater flexibility, more control, and the possibility of developing very powerful applications very quickly using VBA while leveraging the interface, features, and functionality of the host Office application (Excel in our case).

Indeed, I’ve since started integrating standalone applications developed for my own clients using C/C++ with Office applications such as Word, Outlook, and Excel. For example, a standalone application written in C/C++ can perform calculations and then automatically send the output to Word in a nicely formatted report, which can then be emailed automatically using Outlook. VBA allows you to do this sort of thing too. We’ll cover some of these cool things, such as making Excel talk to ...

Get Excel Scientific and Engineering Cookbook 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.