Preface
Visual Basic for Applications (VBA) has been around for decades, and was upgraded in 2010 with the introduction of VBA 7 in Microsoft Office applications. Millions of users worldwide use VBA daily, making it indispensable for streamlining work within the Office Suite.
It is probably one of the easiest coding languages to learn, and unique in the sense that it is associated with specific applications. Where other coding languages can be used to create standalone programs, VBA will function only within the MS Office environment.
VBA's main purpose is to automate tasks in Microsoft Office products, and its most outstanding feature is its simplicity. Even if you know nothing about programming, you will see results within the first day.
Starting with the macro recorder, you can create your first code by clicking a record button, and the recorder will write code for every single step you execute. Experienced coders can write more effective code, yet it enables complete novices to automate lengthy and time-consuming processes. With this recorded code as the basis, you can become adventurous by making small changes, teaching yourself as you go along.
Another useful feature is that VBA can control one application from another. You can, for example, automatically create a report in MS Word or PowerPoint, from existing Excel data.
Companies other than Microsoft also use VBA to automate some tasks. These include ArcGIS, AutoCAD, CorelDraw, LibreOffice, SolidWorks, and WordPerfect.
This book is designed to teach you the language, first on an elementary level, and later moving to more advanced terrain. We start with recording a macro, then proceed to writing your own Sub
procedures. Next, we teach you the object model and language elements, program flow, error handling, user forms for capturing data, and eventually creating custom functions.
Each chapter contains code samples to explain the principles taught in each recipe. As an added bonus, there are action videos to clarify each working sample.