Introduction |
|
xxix | |
Part 1 Recording Macros and Getting Started with VBA |
|
1 | (114) |
|
Chapter 1 Recording and Running Macros in the Office Applications |
|
|
3 | (32) |
|
What Is VBA and What Can You Do with It? |
|
|
3 | (2) |
|
The Difference between Visual Basic and Visual Basic for Applications |
|
|
4 | (1) |
|
What Are Visual Basic .NET and Visual Basic Express? |
|
|
5 | (1) |
|
Understanding Macro Basics |
|
|
5 | (1) |
|
|
6 | (18) |
|
Displaying the Developer Tab on the Ribbon |
|
|
7 | (1) |
|
|
8 | (2) |
|
Starting the Macro Recorder |
|
|
10 | (3) |
|
|
13 | (11) |
|
|
24 | (1) |
|
Recording a Sample Word Macro |
|
|
25 | (2) |
|
Recording a Sample Excel Macro |
|
|
27 | (3) |
|
Create a Personal Macro Workbook If You Don't Have One Yet |
|
|
28 | (1) |
|
|
29 | (1) |
|
Specifying How to Trigger an Existing Macro |
|
|
30 | (1) |
|
Assigning a Macro to a Quick Access Toolbar Button in Word |
|
|
30 | (1) |
|
Assigning a Macro to a Shortcut Key Combination |
|
|
31 | (1) |
|
|
31 | (2) |
|
|
33 | (2) |
|
Chapter 2 Getting Started with the Visual Basic Editor |
|
|
35 | (34) |
|
Opening the Visual Basic Editor |
|
|
35 | (3) |
|
Opening the Visual Basic Editor with a Macro Selected |
|
|
36 | (1) |
|
Opening the Visual Basic Editor Directly |
|
|
37 | (1) |
|
|
37 | (1) |
|
Using the Visual Basic Editor's Main Windows |
|
|
38 | (13) |
|
|
39 | (3) |
|
|
42 | (1) |
|
|
43 | (5) |
|
|
48 | (2) |
|
|
50 | (1) |
|
Setting Properties for a Project |
|
|
51 | (2) |
|
Customizing the Visual Basic Editor |
|
|
53 | (13) |
|
Choosing Editor and View Preferences |
|
|
54 | (7) |
|
Choosing and Laying Out the Editor Windows |
|
|
61 | (1) |
|
Customizing the Toolbar and Menu Bar |
|
|
61 | (1) |
|
|
62 | (4) |
|
|
66 | (3) |
|
Chapter 3 Editing Recorded Macros |
|
|
69 | (24) |
|
Testing a Macro in the Visual Basic Editor |
|
|
70 | (5) |
|
|
71 | (2) |
|
|
73 | (1) |
|
|
74 | (1) |
|
|
75 | (1) |
|
|
75 | (4) |
|
Stepping Through the Transpose_Word_Right Macro |
|
|
77 | (1) |
|
Running the Transpose_Word_Right Macro |
|
|
77 | (1) |
|
Creating a Transpose_Word_Left Macro |
|
|
77 | (2) |
|
|
79 | (1) |
|
|
79 | (5) |
|
Unhiding the Personal Macro Workbook |
|
|
79 | (2) |
|
Opening a Macro for Editing |
|
|
81 | (1) |
|
|
82 | (2) |
|
Editing a PowerPoint Macro |
|
|
84 | (6) |
|
Reducing the Size of Your Macro |
|
|
88 | (1) |
|
|
89 | (1) |
|
|
90 | (3) |
|
Chapter 4 Creating Code from Scratch in the Visual Basic Editor |
|
|
93 | (22) |
|
Setting Up the Visual Basic Editor to Create Macros |
|
|
93 | (2) |
|
Creating a Procedure for Word |
|
|
95 | (6) |
|
Creating a Macro for Excel |
|
|
101 | (5) |
|
Creating a Procedure for PowerPoint |
|
|
106 | (6) |
|
Creating a Procedure for Access |
|
|
112 | (1) |
|
|
113 | (2) |
Part 2 Learning How to Work with VBA |
|
115 | (98) |
|
Chapter 5 Understanding the Essentials of VBA Syntax |
|
|
117 | (18) |
|
|
117 | (1) |
|
|
118 | (1) |
|
|
119 | (1) |
|
|
119 | (1) |
|
|
119 | (4) |
|
|
123 | (1) |
|
|
124 | (1) |
|
|
124 | (1) |
|
|
124 | (2) |
|
|
126 | (1) |
|
|
126 | (3) |
|
Specifying Argument Names vs. Omitting Argument Names |
|
|
127 | (1) |
|
When to Include the Parentheses around an Argument List |
|
|
128 | (1) |
|
|
129 | (1) |
|
|
129 | (1) |
|
|
130 | (1) |
|
|
130 | (1) |
|
|
130 | (2) |
|
|
132 | (3) |
|
Chapter 6 Working with Variables, Constants, and Enumerations |
|
|
135 | (24) |
|
|
136 | (19) |
|
Choosing Names for Variables |
|
|
136 | (2) |
|
|
138 | (3) |
|
Choosing the Scope and Lifetime of a Variable |
|
|
141 | (7) |
|
Specifying the Data Type for a Variable |
|
|
148 | (7) |
|
|
155 | (1) |
|
Declaring Your Own Constants |
|
|
155 | (1) |
|
Choosing the Scope or Lifetime for Constants |
|
|
156 | (1) |
|
Working with Enumerations |
|
|
156 | (1) |
|
|
157 | (2) |
|
Chapter 7 Using Array Variables |
|
|
159 | (26) |
|
|
159 | (8) |
|
|
161 | (2) |
|
Storing Values in an Array |
|
|
163 | (1) |
|
|
164 | (1) |
|
Declaring a Dynamic Array |
|
|
165 | (1) |
|
|
165 | (1) |
|
Returning Information from an Array |
|
|
166 | (1) |
|
|
166 | (1) |
|
Determining Whether a Variable Is an Array |
|
|
166 | (1) |
|
Finding the Bounds of an Array |
|
|
167 | (1) |
|
|
167 | (4) |
|
|
171 | (11) |
|
Performing a Linear Search Through an Array |
|
|
172 | (5) |
|
Binary Searching an Array |
|
|
177 | (5) |
|
|
182 | (3) |
|
Chapter 8 Finding the Objects, Methods, and Properties You Need |
|
|
185 | (28) |
|
|
185 | (5) |
|
|
185 | (2) |
|
Understanding Creatable Objects |
|
|
187 | (1) |
|
|
187 | (1) |
|
|
188 | (2) |
|
|
190 | (2) |
|
Working with an Object in a Collection |
|
|
191 | (1) |
|
Adding an Object to a Collection |
|
|
192 | (1) |
|
Finding the Objects You Need |
|
|
192 | (14) |
|
Using the Macro Recorder to Add Code for the Objects You Need |
|
|
192 | (3) |
|
|
195 | (6) |
|
Using Help to Find the Object You Need |
|
|
201 | (4) |
|
Using the Auto List Members Feature |
|
|
205 | (1) |
|
Using Object Variables to Represent Objects |
|
|
206 | (3) |
|
|
209 | (2) |
|
|
211 | (2) |
Part 3 Making Decisions and Using Loops and Functions |
|
213 | (114) |
|
Chapter 9 Using Built-In Functions |
|
|
215 | (36) |
|
|
215 | (2) |
|
|
217 | (7) |
|
Passing Arguments to a Function |
|
|
219 | (1) |
|
Using Functions to Convert Data |
|
|
220 | (1) |
|
Using the Asc Function to Return a Character Code |
|
|
221 | (1) |
|
Using the Val Function to Extract a Number from the Start of a String |
|
|
221 | (2) |
|
Using the Str Function to Convert a Number into a String |
|
|
223 | (1) |
|
Using the Format Function to Format an Expression |
|
|
224 | (18) |
|
Using Predefined Numeric Formats |
|
|
225 | (1) |
|
Creating a Numeric Format |
|
|
226 | (1) |
|
Creating a Date or Time Format |
|
|
227 | (1) |
|
|
228 | (1) |
|
Using the Chr Function and Constants to Enter Special Characters in a String |
|
|
229 | (1) |
|
Using Functions to Manipulate Strings |
|
|
230 | (1) |
|
Using the Left, Right, and Mid Functions to Return Part of a String |
|
|
230 | (2) |
|
|
232 | (1) |
|
|
232 | (1) |
|
|
233 | (2) |
|
Using InStr and InStrRev to Find a String Within Another String |
|
|
235 | (2) |
|
Using LTrim, RTrim, and Trim to Remove Spaces from a String |
|
|
237 | (1) |
|
Using Len to Check the Length of a String |
|
|
238 | (2) |
|
Using StrConv, LCase, and UCase to Change the Case of a String |
|
|
240 | (1) |
|
Using the StrComp Function to Compare Apples to Apples |
|
|
241 | (1) |
|
Using VBA's Mathematical Functions |
|
|
242 | (2) |
|
Using VBA's Date and Time Functions |
|
|
244 | (2) |
|
Using the DatePart Function to Parse Dates |
|
|
244 | (1) |
|
Calculating Time Intervals Using the DateDi ff Function |
|
|
245 | (1) |
|
Using the DateAdd Function to Add or Subtract Time from a Date |
|
|
246 | (1) |
|
Using File-Management Functions |
|
|
246 | (2) |
|
Checking Whether a File Exists Using the Di r Function |
|
|
246 | (2) |
|
Returning the Current Path |
|
|
248 | (1) |
|
|
248 | (3) |
|
Chapter 10 Creating Your Own Functions |
|
|
251 | (22) |
|
|
252 | (2) |
|
|
254 | (4) |
|
Starting a Function Manually |
|
|
254 | (1) |
|
Starting a Function by Using the Add Procedure Dialog Box |
|
|
254 | (2) |
|
Passing Arguments to a Function |
|
|
256 | (1) |
|
Declaring the Data Types of Arguments |
|
|
257 | (1) |
|
Specifying an Optional Argument |
|
|
257 | (1) |
|
Controlling the Scope of a Function |
|
|
258 | (1) |
|
Examples of Functions for All VBA-Enabled Office Applications |
|
|
258 | (5) |
|
How Functions Return Information |
|
|
260 | (1) |
|
Returning Text Data from a Function |
|
|
260 | (3) |
|
Creating a Function for Word |
|
|
263 | (2) |
|
Creating a Function for Excel |
|
|
265 | (2) |
|
Creating a Function for PowerPoint |
|
|
267 | (2) |
|
Creating a Function for Access |
|
|
269 | (2) |
|
|
271 | (2) |
|
Chapter 11 Making Decisions in Your Code |
|
|
273 | (24) |
|
How Do You Compare Things in VBA? |
|
|
274 | (1) |
|
Testing Multiple Conditions by Using Logical Operators |
|
|
275 | (16) |
|
|
278 | (1) |
|
|
278 | (2) |
|
If...Then...Else Statements |
|
|
280 | (2) |
|
If...Then...Elself...Else Statements |
|
|
282 | (5) |
|
Creating Loops with If and GoTo |
|
|
287 | (2) |
|
|
289 | (2) |
|
|
291 | (3) |
|
|
291 | (1) |
|
|
292 | (2) |
|
|
294 | (1) |
|
|
294 | (3) |
|
Chapter 12 Using Loops to Repeat Actions |
|
|
297 | (30) |
|
When Should You Use a Loop? |
|
|
297 | (1) |
|
Understanding the Basics of Loops |
|
|
298 | (1) |
|
Using For...Loops for Fixed Repetitions |
|
|
299 | (11) |
|
|
299 | (9) |
|
|
308 | (1) |
|
Using an Exit For Statement |
|
|
308 | (1) |
|
Using Do...Loops for Variable Numbers of Repetitions |
|
|
309 | (1) |
|
|
310 | (11) |
|
|
314 | (2) |
|
|
316 | (2) |
|
|
318 | (1) |
|
Using an Exit Do Statement |
|
|
319 | (1) |
|
Is the Exit Do Statement Bad Practice? |
|
|
320 | (1) |
|
|
321 | (1) |
|
|
322 | (3) |
|
|
325 | (1) |
|
|
326 | (1) |
Part 4 Using Message Boxes, Input Boxes, and Dialog Boxes |
|
327 | (146) |
|
Chapter 13 Getting User Input with Message Boxes and Input Boxes |
|
|
329 | (22) |
|
|
330 | (1) |
|
Displaying Status-Bar Messages in Word and Excel |
|
|
331 | (2) |
|
|
333 | (12) |
|
The Pros and Cons of Message Boxes |
|
|
333 | (1) |
|
|
334 | (1) |
|
Displaying a Simple Message Box |
|
|
335 | (1) |
|
Displaying a Multiline Message Box |
|
|
336 | (1) |
|
Choosing Buttons for a Message Box |
|
|
337 | (1) |
|
Choosing an Icon for a Message Box |
|
|
338 | (1) |
|
Setting a Default Button for a Message Box |
|
|
339 | (1) |
|
Controlling the Modality of a Message Box |
|
|
340 | (1) |
|
Specifying a Title for a Message Box |
|
|
341 | (1) |
|
Title Bars Can Provide Useful Information |
|
|
342 | (1) |
|
Adding a Help Button to a Message Box |
|
|
342 | (1) |
|
Specifying a Help File for a Message Box |
|
|
343 | (1) |
|
Using Some Arguments Without Others |
|
|
344 | (1) |
|
Retrieving a Value from a Message Box |
|
|
344 | (1) |
|
|
345 | (3) |
|
|
346 | (2) |
|
Retrieving Input from an Input Box |
|
|
348 | (1) |
|
Forms: When Message Boxes and Input Boxes Won't Suffice |
|
|
348 | (1) |
|
|
349 | (2) |
|
Chapter 14 Creating Simple Custom Dialog Boxes |
|
|
351 | (72) |
|
When Should You Use a Custom Dialog Box? |
|
|
351 | (1) |
|
Creating a Custom Dialog Box |
|
|
352 | (34) |
|
|
354 | (1) |
|
|
354 | (1) |
|
Choosing User-Form Grid Settings |
|
|
355 | (3) |
|
|
358 | (2) |
|
Adding Controls to the User Form |
|
|
360 | (3) |
|
|
363 | (1) |
|
|
364 | (1) |
|
|
365 | (2) |
|
Changing the Caption on a Control |
|
|
367 | (1) |
|
Key Properties of the Toolbox Controls |
|
|
368 | (18) |
|
Working with Groups of Controls |
|
|
386 | (5) |
|
|
386 | (1) |
|
|
386 | (1) |
|
|
387 | (1) |
|
Deleting Grouped Controls |
|
|
387 | (1) |
|
Working with One Control in a Group |
|
|
387 | (1) |
|
|
388 | (1) |
|
|
389 | (1) |
|
Adjusting the Tab Order of a Form |
|
|
389 | (2) |
|
Linking a Form to a Procedure |
|
|
391 | (2) |
|
Loading and Unloading a Form |
|
|
392 | (1) |
|
Displaying and Hiding a Form |
|
|
392 | (1) |
|
Setting a Default Command Button |
|
|
393 | (1) |
|
Retrieving the User's Choices from a Dialog Box |
|
|
393 | (4) |
|
Returning a String from a Text Box |
|
|
393 | (1) |
|
Returning a Value from an Option Button |
|
|
394 | (1) |
|
Returning a Value from a Check Box |
|
|
395 | (1) |
|
Returning a Value from a List Box |
|
|
395 | (1) |
|
Returning a Value from a Combo Box |
|
|
396 | (1) |
|
Examples Showing How to Connect Forms to Procedures |
|
|
397 | (18) |
|
Word Example: The Move-Paragraph Procedure |
|
|
397 | (12) |
|
General Example: Opening a File from a List Box |
|
|
409 | (1) |
|
|
409 | (2) |
|
Creating the Code for the User Form |
|
|
411 | (4) |
|
Using an Application's Built-In Dialog Boxes |
|
|
415 | (6) |
|
Displaying a Built-In Dialog Box |
|
|
415 | (4) |
|
Setting and Restoring Options in a Built-In Dialog Box |
|
|
419 | (1) |
|
Which Button Did the User Choose in a Dialog Box? |
|
|
419 | (1) |
|
Specifying a Time-Out for a Dialog Box |
|
|
420 | (1) |
|
|
421 | (2) |
|
Chapter 15 Creating Complex Forms |
|
|
423 | (50) |
|
Creating and Working with Complex Dialog Boxes |
|
|
424 | (21) |
|
Updating a Dialog Box to Reflect the User's Choices |
|
|
424 | (1) |
|
Revealing a Hidden Part of a Form |
|
|
424 | (5) |
|
Tracking a Procedure in a Form |
|
|
429 | (3) |
|
Using Multipage Dialog Boxes and TabStrip Controls |
|
|
432 | (11) |
|
Creating a Modeless Dialog Box |
|
|
443 | (1) |
|
Specifying a Form's Location Onscreen |
|
|
444 | (1) |
|
Using Events to Control Forms |
|
|
445 | (27) |
|
Events Unique to the UserForm Object |
|
|
448 | (5) |
|
Events That Apply to Both UserForms and Container Controls |
|
|
453 | (5) |
|
Events That Apply to Many or Most Controls |
|
|
458 | (13) |
|
Events That Apply Only to a Few Controls |
|
|
471 | (1) |
|
|
472 | (1) |
Part 5 Creating Effective Code |
|
473 | (102) |
|
Chapter 16 Building Modular Code and Using Classes |
|
|
475 | (30) |
|
|
475 | (17) |
|
|
476 | (1) |
|
Advantages of Using Modular Code |
|
|
476 | (1) |
|
How to Approach Creating Modular Code |
|
|
477 | (1) |
|
Arranging Your Code in Modules |
|
|
477 | (1) |
|
|
477 | (2) |
|
Making Logical Improvements to Your Code |
|
|
479 | (7) |
|
Making Visual Improvements to Your Code |
|
|
486 | (6) |
|
Creating and Using Classes |
|
|
492 | (11) |
|
What Can You Do with Class Modules? |
|
|
492 | (1) |
|
A Brief Overview of Classes |
|
|
493 | (1) |
|
|
493 | (1) |
|
|
494 | (1) |
|
|
494 | (1) |
|
Setting the Instancing Property |
|
|
495 | (1) |
|
Declaring Variables and Constants for the Class |
|
|
495 | (1) |
|
Adding Properties to the Class |
|
|
495 | (5) |
|
Adding Methods to a Class |
|
|
500 | (1) |
|
|
501 | (2) |
|
|
503 | (2) |
|
Chapter 17 Debugging Your Code and Handling Errors |
|
|
505 | (32) |
|
|
505 | (7) |
|
The Different Types of Errors |
|
|
507 | (1) |
|
|
507 | (1) |
|
|
507 | (3) |
|
|
510 | (1) |
|
|
511 | (1) |
|
|
512 | (11) |
|
|
513 | (2) |
|
The Step Over and Step Out Commands |
|
|
515 | (1) |
|
|
515 | (1) |
|
|
516 | (4) |
|
|
520 | (2) |
|
The Call Stack Dialog Box |
|
|
522 | (1) |
|
Dealing with Infinite Loops |
|
|
523 | (1) |
|
Dealing with Runtime Errors |
|
|
523 | (8) |
|
When Should You Write an Error Handler? |
|
|
524 | (1) |
|
|
524 | (2) |
|
|
526 | (1) |
|
|
527 | (4) |
|
Getting a Description of an Error |
|
|
531 | (1) |
|
|
531 | (1) |
|
|
531 | (1) |
|
Handling User Interrupts in Word, and Excel |
|
|
532 | (1) |
|
Disabling User Input While a Procedure Is Running |
|
|
532 | (1) |
|
Disabling User Input While Part of a Macro Is Running |
|
|
533 | (1) |
|
|
533 | (2) |
|
|
535 | (2) |
|
Chapter 18 Building Well-Behaved Code |
|
|
537 | (16) |
|
What Is a Well-Behaved Macro? |
|
|
537 | (2) |
|
Retaining or Restoring the User Environment |
|
|
539 | (1) |
|
Leaving the User in the Best Position to Continue Working |
|
|
540 | (1) |
|
Keeping the User Informed During the Procedure |
|
|
541 | (7) |
|
|
543 | (1) |
|
Displaying Information at the Beginning of a Macro |
|
|
544 | (1) |
|
Communicating with the User via a Message Box or Dialog Box at the End of a Macro |
|
|
544 | (1) |
|
|
544 | (4) |
|
Making Sure a Macro Is Running Under Suitable Conditions |
|
|
548 | (1) |
|
Cleaning Up After a Procedure |
|
|
549 | (2) |
|
Undoing Changes a Macro Has Made |
|
|
549 | (1) |
|
Removing Scratch Files and Folders |
|
|
549 | (2) |
|
|
551 | (2) |
|
Chapter 19 Exploring VBA's Security Features |
|
|
553 | (22) |
|
Understanding How VBA Implements Security |
|
|
553 | (4) |
|
Signing Your Macro Projects with Digital Signatures |
|
|
557 | (11) |
|
What Is a Digital Certificate? |
|
|
557 | (1) |
|
Getting a Digital Certificate |
|
|
558 | (10) |
|
Choosing a Suitable Level of Security |
|
|
568 | (4) |
|
Understanding the Security Threats Posed by VBA |
|
|
568 | (1) |
|
Protecting Against Macro Viruses |
|
|
568 | (1) |
|
Specifying a Suitable Security Setting |
|
|
569 | (1) |
|
Additional Office Security Features |
|
|
570 | (1) |
|
|
571 | (1) |
|
|
572 | (2) |
|
|
574 | (1) |
Part 6 Programming the Office Applications |
|
575 | (258) |
|
Chapter 20 Understanding the Word Object Model and Key Objects |
|
|
577 | (34) |
|
Examining the Word Object Model |
|
|
577 | (4) |
|
Working with the Documents Collection and the Document Object |
|
|
581 | (1) |
|
|
581 | (1) |
|
|
582 | (1) |
|
|
582 | (6) |
|
Saving a File for the First Time or as a Different File |
|
|
582 | (5) |
|
Saving a Document That Has Already Been Saved |
|
|
587 | (1) |
|
Saving All Open Documents |
|
|
587 | (1) |
|
Checking Whether a Document Contains Unsaved Changes |
|
|
587 | (1) |
|
|
588 | (4) |
|
|
592 | (1) |
|
Changing a Document's Template |
|
|
592 | (1) |
|
|
592 | (2) |
|
Working with the ActiveDocument Object |
|
|
594 | (2) |
|
Working with the Selection Object |
|
|
596 | (9) |
|
Checking the Type of Selection |
|
|
596 | (1) |
|
Checking the Story Type of the Selection |
|
|
597 | (2) |
|
Getting Other Information About the Current Selection |
|
|
599 | (4) |
|
Inserting Text at a Selection |
|
|
603 | (1) |
|
Inserting a Paragraph in a Selection |
|
|
603 | (1) |
|
|
604 | (1) |
|
Extending an Existing Selection |
|
|
604 | (1) |
|
Collapsing an Existing Selection |
|
|
605 | (1) |
|
Creating and Using Ranges |
|
|
605 | (2) |
|
|
606 | (1) |
|
|
607 | (1) |
|
Using the Duplicate Property to Store or Copy Formatting |
|
|
607 | (1) |
|
|
607 | (2) |
|
Making Sure Hyperlinks Require Ctrl+Clicking |
|
|
607 | (1) |
|
|
608 | (1) |
|
Setting a Default File Path |
|
|
608 | (1) |
|
Turning Off Track Changes |
|
|
609 | (1) |
|
|
609 | (2) |
|
Chapter 21 Working with Widely Used Objects in Word |
|
|
611 | (34) |
|
Using Find and Replace via VBA |
|
|
611 | (6) |
|
Understanding the Syntax of the Execute Method |
|
|
613 | (3) |
|
Putting Find and Replace to Work |
|
|
616 | (1) |
|
Working with Headers, Footers, and Page Numbers |
|
|
617 | (6) |
|
Understanding How VBA Implements Headers and Footers |
|
|
617 | (1) |
|
Getting to a Header or Footer |
|
|
618 | (1) |
|
Checking to See If a Header or Footer Exists |
|
|
618 | (1) |
|
Linking to the Header or Footer in the Previous Section |
|
|
619 | (1) |
|
Creating a Different First-Page Header |
|
|
619 | (1) |
|
Creating Different Odd- and Even-Page Headers |
|
|
619 | (1) |
|
Adding Page Numbers to Your Headers and Footers |
|
|
620 | (3) |
|
Working with Sections, Page Setup, Windows, and Views |
|
|
623 | (6) |
|
Adding a Section to a Document |
|
|
623 | (1) |
|
|
624 | (1) |
|
Opening a New Window Containing an Open Document |
|
|
625 | (1) |
|
Closing All Windows Except the First for a Document |
|
|
625 | (1) |
|
|
626 | (1) |
|
Displaying the Document Map for a Window |
|
|
626 | (1) |
|
|
626 | (1) |
|
|
627 | (1) |
|
Positioning and Sizing a Window |
|
|
627 | (1) |
|
Making Sure an Item Is Displayed in the Window |
|
|
628 | (1) |
|
Changing a Document's View |
|
|
628 | (1) |
|
|
628 | (1) |
|
Zooming the View to Display Multiple Pages |
|
|
629 | (1) |
|
|
629 | (13) |
|
|
630 | (1) |
|
|
630 | (1) |
|
Converting Text to a Table |
|
|
631 | (2) |
|
Ensuring That a Selection Is Within a Table |
|
|
633 | (1) |
|
Finding Out Where a Selection Is Within a Table |
|
|
633 | (1) |
|
|
634 | (1) |
|
Adding a Column to a Table |
|
|
635 | (1) |
|
Deleting a Column from a Table |
|
|
636 | (1) |
|
Setting the Width of a Column |
|
|
636 | (1) |
|
|
637 | (1) |
|
|
637 | (1) |
|
Deleting a Row from a Table |
|
|
638 | (1) |
|
Setting the Height of One or More Rows |
|
|
638 | (1) |
|
|
638 | (1) |
|
|
638 | (1) |
|
Returning the Text in a Cell |
|
|
639 | (1) |
|
|
639 | (1) |
|
|
639 | (1) |
|
Selecting a Range of Cells |
|
|
640 | (1) |
|
Converting a Table or Rows to Text |
|
|
641 | (1) |
|
|
642 | (3) |
|
Chapter 22 Understanding the Excel Object Model and Key Objects |
|
|
645 | (26) |
|
Getting an Overview of the Excel Object Model |
|
|
645 | (1) |
|
Understanding Excel's Creatable Objects |
|
|
646 | (1) |
|
|
647 | (10) |
|
|
647 | (2) |
|
|
649 | (3) |
|
|
652 | (1) |
|
|
652 | (2) |
|
|
654 | (1) |
|
|
655 | (1) |
|
|
655 | (1) |
|
Working with the Active Workbook Object |
|
|
656 | (1) |
|
|
657 | (5) |
|
|
657 | (1) |
|
|
658 | (1) |
|
Copying or Moving a Worksheet |
|
|
658 | (1) |
|
|
659 | (1) |
|
|
660 | (2) |
|
Working with the ActiveSheet Object |
|
|
662 | (2) |
|
Working with the Active Cell or Selection |
|
|
662 | (1) |
|
Working with the Active Cell |
|
|
662 | (2) |
|
Working with the User's Selection |
|
|
664 | (4) |
|
|
664 | (1) |
|
Working with a Range of Cells |
|
|
665 | (1) |
|
|
665 | (1) |
|
|
666 | (1) |
|
Working with a Named Range |
|
|
666 | (1) |
|
Working with the Used Range |
|
|
666 | (1) |
|
Working with SpecialCells |
|
|
666 | (2) |
|
Entering a Formula in a Cell |
|
|
668 | (1) |
|
|
668 | (2) |
|
Setting Options in the Application Object |
|
|
668 | (1) |
|
Setting Options in a Workbook |
|
|
669 | (1) |
|
|
670 | (1) |
|
Chapter 23 Working with Widely Used Objects in Excel |
|
|
671 | (16) |
|
|
671 | (7) |
|
|
671 | (2) |
|
Specifying the Source Data for the Chart |
|
|
673 | (1) |
|
|
673 | (1) |
|
Working with Series in the Chart |
|
|
673 | (3) |
|
Adding a Legend to the Chart |
|
|
676 | (1) |
|
|
677 | (1) |
|
Working with a Chart Axis |
|
|
677 | (1) |
|
Formatting Headers and Footers |
|
|
678 | (1) |
|
Working with Windows Objects |
|
|
678 | (3) |
|
Opening a New Window on a Workbook |
|
|
678 | (1) |
|
|
679 | (1) |
|
|
679 | (1) |
|
Arranging and Resizing Windows |
|
|
679 | (2) |
|
Zooming a Window and Setting Display Options |
|
|
681 | (1) |
|
Working with Find and Replace |
|
|
681 | (3) |
|
Searching with the Find Method |
|
|
681 | (2) |
|
Continuing a Search with the FindNext and FindPrevious Methods |
|
|
683 | (1) |
|
Replacing with the Replace Method |
|
|
683 | (1) |
|
Searching for and Replacing Formatting |
|
|
684 | (1) |
|
|
684 | (1) |
|
|
685 | (2) |
|
Chapter 24 Understanding the PowerPoint Object Model and Key Objects |
|
|
687 | (22) |
|
Getting an Overview of the PowerPoint Object Model |
|
|
687 | (1) |
|
Understanding PowerPoint's Creatable Objects |
|
|
688 | (1) |
|
Working with Presentations |
|
|
689 | (6) |
|
Creating a New Presentation Based on the Default Template |
|
|
689 | (1) |
|
Opening an Existing Presentation |
|
|
690 | (1) |
|
Opening a Presentation from the Cloud |
|
|
690 | (1) |
|
|
691 | (2) |
|
|
693 | (1) |
|
Exporting a Presentation or Some Slides to Graphics |
|
|
694 | (1) |
|
|
694 | (1) |
|
Working with the Active Presentation |
|
|
695 | (1) |
|
Working with Windows and Views |
|
|
695 | (4) |
|
Working with the Active Window |
|
|
696 | (1) |
|
Opening a New Window on a Presentation |
|
|
696 | (1) |
|
|
696 | (1) |
|
|
697 | (1) |
|
Arranging and Resizing Windows |
|
|
697 | (1) |
|
|
698 | (1) |
|
|
698 | (1) |
|
|
699 | (6) |
|
Adding a Slide to a Presentation |
|
|
699 | (1) |
|
Inserting Slides from an Existing Presentation |
|
|
700 | (1) |
|
Finding a Slide by Its ID Number |
|
|
700 | (1) |
|
Changing the Layout of an Existing Slide |
|
|
701 | (1) |
|
Deleting an Existing Slide |
|
|
701 | (1) |
|
Copying and Pasting a Slide |
|
|
701 | (1) |
|
|
702 | (1) |
|
|
702 | (1) |
|
Accessing a Slide by Name |
|
|
702 | (1) |
|
Working with a Range of Slides |
|
|
702 | (1) |
|
|
703 | (1) |
|
Setting a Transition for a Slide, a Range of Slides, or a Master |
|
|
704 | (1) |
|
|
705 | (2) |
|
Working with the Slide Master |
|
|
705 | (1) |
|
Working with the Title Master |
|
|
706 | (1) |
|
Working with the Handout Master |
|
|
706 | (1) |
|
Working with the Notes Master |
|
|
706 | (1) |
|
|
706 | (1) |
|
|
707 | (2) |
|
Chapter 25 Working with Shapes and Running Slide Shows |
|
|
709 | (22) |
|
|
709 | (14) |
|
|
709 | (6) |
|
|
715 | (1) |
|
|
715 | (1) |
|
Repositioning and Resizing a Shape |
|
|
715 | (1) |
|
Copying Formatting from One Shape to Another |
|
|
716 | (1) |
|
Working with Text in a Shape |
|
|
716 | (4) |
|
Animating a Shape or a Range of Shapes |
|
|
720 | (3) |
|
Working with Headers and Footers |
|
|
723 | (2) |
|
Returning the Header or Footer Object You Want |
|
|
723 | (1) |
|
Displaying or Hiding a Header or Footer Object |
|
|
723 | (1) |
|
Setting the Text in a Header or Footer |
|
|
723 | (1) |
|
Setting the Format for Date and Time Headers and Footers |
|
|
724 | (1) |
|
Setting Up and Running a Slide Show |
|
|
725 | (4) |
|
Controlling the Show Type |
|
|
725 | (1) |
|
|
726 | (1) |
|
|
727 | (1) |
|
|
727 | (1) |
|
Changing the Size and Position of a Slide Show |
|
|
728 | (1) |
|
|
728 | (1) |
|
Pausing the Show and Using White and Black Screens |
|
|
728 | (1) |
|
Starting and Stopping Custom Shows |
|
|
729 | (1) |
|
|
729 | (1) |
|
|
729 | (2) |
|
Chapter 26 Understanding the Outlook Object Model and Key Objects |
|
|
731 | (24) |
|
Getting an Overview of the Outlook Object Model |
|
|
731 | (4) |
|
|
732 | (1) |
|
Understanding Where Outlook Stores VBA Macros |
|
|
733 | (1) |
|
Understanding Outlook's Most Common Creatable Objects |
|
|
734 | (1) |
|
Working with the Application Object |
|
|
735 | (5) |
|
Introducing the NameSpace Object |
|
|
735 | (1) |
|
|
735 | (3) |
|
Understanding Inspectors and Explorers |
|
|
738 | (1) |
|
|
739 | (1) |
|
|
740 | (1) |
|
Understanding General Methods for Working with Outlook Objects |
|
|
740 | (4) |
|
|
740 | (1) |
|
|
741 | (1) |
|
Using the PrintOut Method |
|
|
741 | (1) |
|
|
742 | (1) |
|
|
742 | (2) |
|
|
744 | (3) |
|
|
744 | (1) |
|
Working with the Contents of a Message |
|
|
744 | (1) |
|
Adding an Attachment to a Message |
|
|
745 | (1) |
|
|
746 | (1) |
|
Working with Calendar Items |
|
|
747 | (2) |
|
Creating a New Calendar Item |
|
|
747 | (1) |
|
Working with the Contents of a Calendar Item |
|
|
747 | (2) |
|
Working with Tasks and Task Requests |
|
|
749 | (1) |
|
|
749 | (1) |
|
Working with the Contents of a Task Item |
|
|
749 | (1) |
|
Assigning a Task to a Colleague |
|
|
750 | (1) |
|
|
750 | (2) |
|
|
752 | (3) |
|
Chapter 27 Working with Events in Outlook |
|
|
755 | (20) |
|
How Event-Handler Procedures Differ from Ordinary Macros |
|
|
755 | (1) |
|
Working with Application-Level Events |
|
|
756 | (6) |
|
|
758 | (1) |
|
|
758 | (1) |
|
|
759 | (1) |
|
|
760 | (1) |
|
Using the AdvancedSearchComplete and the AdvancedSearchStopped Events |
|
|
760 | (1) |
|
Using the MAPILogonComplete Event |
|
|
761 | (1) |
|
|
761 | (1) |
|
Using the OptionsPagesAdd Event |
|
|
762 | (1) |
|
Working with Item-Level Events |
|
|
762 | (10) |
|
Declaring an Object Variable and Initializing an Event |
|
|
763 | (1) |
|
Understanding the Events That Apply to All Message Items |
|
|
764 | (2) |
|
Understanding the Events That Apply to Explorers, Inspectors, and Views |
|
|
766 | (4) |
|
Events That Apply to Folders |
|
|
770 | (1) |
|
Understanding the Events That Apply to Items and Results Objects |
|
|
771 | (1) |
|
Understanding the Events That Apply to Reminders |
|
|
771 | (1) |
|
Understanding the Events That Apply to Synchronization |
|
|
771 | (1) |
|
Understanding Quick Steps |
|
|
772 | (1) |
|
|
773 | (2) |
|
Chapter 28 Understanding the Access Object Model and Key Objects |
|
|
775 | (26) |
|
Getting Started with VBA in Access |
|
|
775 | (9) |
|
Creating a Module in the VBA Editor |
|
|
778 | (1) |
|
|
778 | (1) |
|
|
778 | (1) |
|
Creating an Access-Style Macro to Run a Function |
|
|
778 | (3) |
|
Translating an Access-Style Macro into a VBA Macro |
|
|
781 | (1) |
|
Using an AutoExec Macro to Initialize an Access Session |
|
|
782 | (1) |
|
|
782 | (1) |
|
Understanding the Option Compare Database Statement |
|
|
783 | (1) |
|
Getting an Overview of the Access Object Model |
|
|
784 | (1) |
|
Understanding Creatable Objects in Access |
|
|
784 | (1) |
|
Opening and Closing Databases |
|
|
785 | (8) |
|
Using the CurrentDb Method to Return the Current Database |
|
|
785 | (1) |
|
Closing the Current Database and Opening a Different Database |
|
|
786 | (2) |
|
Communicating Between Office Applications |
|
|
788 | (2) |
|
Opening Multiple Databases at Once |
|
|
790 | (2) |
|
|
792 | (1) |
|
Creating and Removing Workspaces |
|
|
792 | (1) |
|
Working with the Screen Object |
|
|
793 | (1) |
|
Using the DoCmd Object to Run Access Commands |
|
|
794 | (6) |
|
Using the OpenForm Method to Open a Form |
|
|
798 | (1) |
|
Using the PrintOut Method to Print an Object |
|
|
798 | (1) |
|
Using the RunMacro Method to Run an Access-Style Macro |
|
|
799 | (1) |
|
|
800 | (1) |
|
Chapter 29 Accessing One Application from Another Application |
|
|
801 | (32) |
|
Understanding the Tools Used to Communicate Between Applications |
|
|
801 | (1) |
|
Using Automation to Transfer Information |
|
|
802 | (13) |
|
Understanding Early and Late Binding |
|
|
803 | (1) |
|
Creating an Object with the CreateObject Function |
|
|
804 | (1) |
|
Returning an Object with the GetObject Function |
|
|
805 | (1) |
|
Examples of Using Automation with the Office Applications |
|
|
805 | (10) |
|
Using the Shell Function to Run an Application |
|
|
815 | (3) |
|
Using Data Objects to Store and Retrieve Information |
|
|
818 | (3) |
|
|
818 | (1) |
|
Storing Information in a Data Object |
|
|
819 | (1) |
|
Returning Information from a Data Object |
|
|
819 | (1) |
|
Assigning Information to the Clipboard |
|
|
820 | (1) |
|
Finding Out Whether a Data Object Contains a Given Format |
|
|
821 | (1) |
|
|
821 | (4) |
|
Using DDEInitiate to Start a DDE Connection |
|
|
822 | (1) |
|
Using DDERequest to Return Text from Another Application |
|
|
822 | (1) |
|
Using DDEPoke to Send Text to Another Application |
|
|
823 | (1) |
|
Using DDEExecute to Have One Application Execute a Command in Another |
|
|
824 | (1) |
|
Using DDETerminate to Close a DDE Channel |
|
|
824 | (1) |
|
Using DDETerminateAll to Close All Open DDE Channels |
|
|
825 | (1) |
|
Communicating via SendKeys |
|
|
825 | (5) |
|
|
830 | (1) |
|
|
830 | (3) |
Appendix A The Bottom Line |
|
833 | (40) |
|
Chapter 1: Recording and Running Macros in the Office Applications |
|
|
833 | (2) |
|
Chapter 2: Getting Started with the Visual Basic Editor |
|
|
835 | (1) |
|
Chapter 3: Editing Recorded Macros |
|
|
836 | (1) |
|
Chapter 4: Creating Code from Scratch in the Visual Basic Editor |
|
|
836 | (3) |
|
Chapter 5: Understanding the Essentials of VBA Syntax |
|
|
839 | (1) |
|
Chapter 6: Working with Variables, Constants, and Enumerations |
|
|
840 | (2) |
|
Chapter 7: Using Array Variables |
|
|
842 | (1) |
|
Chapter 8: Finding the Objects, Methods, and Properties You Need |
|
|
843 | (1) |
|
Chapter 9: Using Built-in Functions |
|
|
844 | (2) |
|
Chapter 10: Creating Your Own Functions |
|
|
846 | (1) |
|
Chapter 11: Making Decisions in Your Code |
|
|
847 | (2) |
|
Chapter 12: Using Loops to Repeat Actions |
|
|
849 | (1) |
|
Chapter 13: Getting User Input with Message Boxes and Input Boxes |
|
|
850 | (1) |
|
Chapter 14: Creating Simple Custom Dialog Boxes |
|
|
851 | (4) |
|
Chapter 15: Creating Complex Forms |
|
|
855 | (1) |
|
Chapter 16: Building Modular Code and Using Classes |
|
|
856 | (2) |
|
Chapter 17: Debugging Your Code and Handling Errors |
|
|
858 | (1) |
|
Chapter 18: Building Well-Behaved Code |
|
|
859 | (1) |
|
Chapter 19: Exploring VBA's Security Features |
|
|
860 | (2) |
|
Chapter 20: Understanding the Word Object Model and Key Objects |
|
|
862 | (1) |
|
Chapter 21: Working with Widely Used Objects in Word |
|
|
863 | (1) |
|
Chapter 22: Understanding the Excel Object Model and Key Objects |
|
|
864 | (1) |
|
Chapter 23: Working with Widely Used Objects in Excel |
|
|
865 | (1) |
|
Chapter 24: Understanding the PowerPoint Object Model and Key Objects |
|
|
866 | (1) |
|
Chapter 25: Working with Shapes and Running Slide Shows |
|
|
867 | (1) |
|
Chapter 26: Understanding the Outlook Object Model and Key Objects |
|
|
868 | (1) |
|
Chapter 27: Working with Events in Outlook |
|
|
869 | (1) |
|
Chapter 28: Understanding the Access Object Model and Key Objects |
|
|
870 | (1) |
|
Chapter 29: Accessing One Application from Another Application |
|
|
871 | (2) |
Index |
|
873 | |