Mastering VBA for Office 2010
Format: PDF / Kindle (mobi) / ePub
A comprehensive guide to the language used to customize Microsoft Office
Visual Basic for Applications (VBA) is the language used for writing macros, automating Office applications, and creating custom applications in Word, Excel, PowerPoint, Outlook, and Access. This complete guide shows both IT professionals and novice developers how to master VBA in order to customize the entire Office suite for specific business needs.
- Office 2010 is the leading productivity suite, and the VBA language enables customizations of all the Office programs; this complete guide gives both novice and experienced programmers the knowledge they need to make maximum use of VBA for Office
- Supported with real-world examples in Word, Excel, PowerPoint, Outlook, and Access, this book offers clear, systematic tutorials with both intermediate and advanced content
- Covers learning how to work with VBA; recording macros; using loops and functions; using message boxes, input boxes, and dialog boxes; creating effective code; XML-based files; ActiveX; the developer tab; content controls; add-ins; embedded macros; and security
Mastering VBA for Office 2010 prepares developers to customize all Microsoft Office 2010 applications for the unique needs of their employers.
10 9 8 7 6 5 4 3 2 1 ffirs.indd ii 7/23/2010 3:55:55 PM Dear Reader, Thank you for choosing Mastering VBA for Microsoft Office 2010. This book is part of a family of premium-quality Sybex books, all of which are written by outstanding authors who combine practical experience with a gift for teaching. Sybex was founded in 1976. More than 30 years later, we’re still committed to producing consistently exceptional books. With each of our titles, we’re working hard to set a new standard for the
selection) or scroll through the displayed list to find the one you want. Figure 2.7 The Complete Word feature automatically completes a term when you’ve typed enough to identify it. If you haven’t typed enough, you can choose from a short list. c02.indd 37 7/22/2010 9:57:07 AM 38 | CHAPTER 2 GETTING STARTED WITH THE VISUAL BASIC EDITOR The easiest way to activate Complete Word when you’re typing code is to press Ctrl+spacebar. You can also choose Edit ÿ Complete Word or click the
switched on by default, but you can switch it, and other features, off by choosing Tools ÿ Options. Figure 2.12 Use the Data Tips feature to check the value of a variable when you’re running code. MARGIN INDICATORS The Margin Indicators feature lets you quickly set a breakpoint, the next statement, or a bookmark by clicking in the margin of the Code window. You’ll look at setting breakpoints, setting the next statement, and setting bookmarks later. (You can just right-click the gray margin on
stepping through the macro that called this one, use the Step Out command. The Step Out command fi nishes executing the current macro or procedure at full speed, but if the code then continues with another procedure, the Visual Basic Editor reverts to Break mode so you can examine that procedure’s code. We’ll explore what it means to call procedures later in this book. Figure 3.4 The Debug toolbar contains commands for running code, stepping into it and out of it, and displaying key windows for
you’ll either have to type in the code for the following example or, better, just copy and paste it from this book’s website at http://www.sybex.com/go/masteringvba2010. Start by opening the PowerPoint Visual Basic Editor: 1. Open PowerPoint, and in the new, blank presentation that’s displayed, add a shape by clicking the Insert tab on the Ribbon, then clicking the Shapes icon in the Illustrations section. 2. Click a rectangle shape of your choice. This will be object 1 in the Shapes