Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống
1
/ 603 trang
THÔNG TIN TÀI LIỆU
Thông tin cơ bản
Định dạng
Số trang
603
Dung lượng
22,84 MB
Nội dung
Table of Contents Introduction Who This Book Is For What This Book Covers How This Book Is Structured What You Need to Use This Book Conventions Errata p2p.wrox.com Part I: Understanding the BASICs Lesson 1: Introducing VBA What is VBA? A Brief History of VBA What VBA Can Do for You Liabilities of VBA Try It Lesson 2: Getting Started with Macros Composing Your First Macro Running A Macro Try It Lesson 3: Introducing the Visual Basic Editor What is the VBE? Try It Lesson 4: Working in the VBE Toolbars in the VBE Macros and Modules Understanding the Code Editing a Macro with Comments and Improvements to the Code Try It Part II: Diving Deeper into VBA Lesson 5: Object-Oriented Programming: An Overview What “Object-Oriented Programming” Means The Object Model Try It Lesson 6: Variables, Data Types, and Constants What is a Variable? Assigning Values to Variables Why You Need Variables Data Types Forcing Variable Declaration Understanding a Variable's Scope Try It Lesson 7: Understanding Objects and Collections Workbooks Cells and Ranges Try It Lesson 8: Working with Ranges Working with Contiguously Populated Ranges Working with Noncontiguously Populated Ranges Try It Lesson 9: Making Decisions with VBA Understanding Logical Operators Choosing between this or that Getting Users to Make Decisions Try It Part III: Beyond the Macro Recorder: Writing Your Own Code Lesson 10: Repeating Actions with Loops What is a Loop? Nesting Loops Try It Lesson 11: Programming Formulas Understanding A1 and R1C1 References Programming Your Formula Solutions with VBA Try It Lesson 12: Working with Arrays What is an Array? The Option Base Statement Boundaries in Arrays Declaring Arrays with Fixed Elements Declaring Dynamic Arrays with Redim and Preserve Try It Lesson 13: Automating Procedures with Worksheet Events What Is an Event? Worksheet Events: An Overview Examples of Common Worksheet Events Try It Lesson 14: Automating Procedures with Workbook Events Workbook Events: An Overview Examples of Common Workbook Events Try It Lesson 15: Handling Duplicate Items and Records Deleting Rows Containing Duplicate Entries Working with Duplicate Data Try It Lesson 16: Using Embedded Controls Working with Form Controls and ActiveX Controls Try It Lesson 17: Programming Charts Adding a Chart to a Chart Sheet Adding an Embedded Chart to a Worksheet Moving a Chart Looping Through All Embedded Charts Try It Lesson 18: Programming PivotTables and PivotCharts Creating a PivotTable Report Understanding PivotCaches Manipulating PivotFields in VBA Manipulating PivotItems with VBA Creating a PivotTables Collection Try It Lesson 19: User-Defined Functions What Is a User-Defined Function? UDF Examples That Solve Common Tasks Volatile Functions Try It Lesson 20: Debugging Your Code What Is Debugging? What Causes Errors? Weapons of Mass Debugging Trapping Errors Try It Part IV: Advanced Programming Techniques Lesson 21: Creating UserForms What Is a UserForm? Creating a UserForm Designing a UserForm Adding Controls to a UserForm Showing a UserForm Where Does the UserForm's Code Go? Closing a UserForm Try It Lesson 22: UserForm Controls and Their Functions Understanding the Frequently Used UserForm Controls Try It Lesson 23: Advanced UserForms The UserForm Toolbar Modal versus Modeless Disabling the UserForm's Close Button Maximizing Your UserForm's Size Selecting and Displaying Photographs on a UserForm Unloading a UserForm Automatically Pre-sorting the ListBox and ComboBox Items Populating ListBoxes and ComboBoxes with Unique Items Displaying a Real-Time Chart in a UserForm Try It Lesson 24: Class Modules What Is a Class? What Is a Class Module? Creating Your Own Objects An Important Benefit of Class Modules Creating Collections Class Modules for Embedded Objects Try It Lesson 25: Add-Ins What Is an Excel Add-In? Creating an Add-In Converting a File to an Add-In Installing an Add-In Creating a User Interface for Your Add-In Closing Add-Ins Removing an Add-In from the Add-Ins List Try It Lesson 26: Managing External Data Creating QueryTables from Web Queries Creating a QueryTable for Access Using Text Files to Store External Data Try It Lesson 27: Data Access with ActiveX Data Objects Introducing ADO An Introduction to Structured Query Language (SQL) Try It Lesson 28: Impressing Your Boss (or at Least Your Friends) Selecting Cells and Ranges Filtering Dates Setting Page Breaks for Specified Areas Using a Comment to Log Changes in a Cell Using the Windows API with VBA Scheduling Your Workbook for Suicide Try It Part V: Interacting with Other Office Applications Lesson 29: Overview of Office Automation from Excel Why Automate Another Application? Understanding Office Automation Try It Lesson 30: Working with Word from Excel Activating a Word Document Creating a New Word Document Copying an Excel Range to a Word Document Printing a Word Document from Excel Importing a Word Document to Excel Try It Lesson 31: Working with Outlook from Excel Opening Outlook Composing an E-mail in Outlook from Excel Putting It All Together E-mailing a Single Worksheet Try It Lesson 32: Working with Access from Excel Adding a Record to an Access Table Exporting an Access Table to an Excel Spreadsheet Creating a New Table in Access Try It Lesson 33: Working with PowerPoint from Excel Creating a New PowerPoint Presentation Copying a Worksheet Range to a PowerPoint Slide Copying Chart Sheets to PowerPoint Slides Running a PowerPoint Presentation from Excel Try It Advertisement End User License Agreement List of Illustrations Figure 1.1 Figure 1.2 Figure 1.3 Figure 2.1 Figure 2.2 Figure 2.3 Figure 2.4 Figure 2.5 Figure 2.6 Figure 2.7 Figure 2.8 Figure 2.9 Figure 2.10 Figure 2.11 Figure 2.12 Figure 2.13 Figure 2.14 Figure 2.15 Figure 2.16 Figure 2.17 Figure 2.18 Figure 3.1 Figure 3.2 Figure 3.3 Figure 3.4 Figure 3.5 Figure 4.1 Figure 4.2 Figure 4.3 Figure 4.4 Figure 4.5 Figure 4.6 Figure 4.7 Figure 4.8 Figure 4.9 Figure 4.10 Figure 4.11 Figure 6.1 Figure 6.2 Figure 6.3 Figure 6.4 Figure 6.5 Figure 6.6 Figure 6.7 Figure 7.1 Figure 7.2 Figure 7.3 Figure 7.4 Figure 7.5 Figure 8.1 Figure 8.2 Figure 8.3 Figure 8.4 Figure 8.5 Figure 8.6 Figure 8.7 Figure 8.8 Figure 8.9 Figure 8.10 Figure 8.11 Figure 8.12 Figure 8.13 Figure 8.14 ... Lesson 25: Add-Ins What Is an Excel Add-In? Creating an Add-In Converting a File to an Add-In Installing an Add-In Creating a User Interface for Your Add-In Closing Add-Ins Removing an Add-In from the Add-Ins List... You find out how to use VBA to automate your work by doing anything from recording a simple one-line macro to writing a complex program with a customized, user-friendly interface that will look nothing like Excel. .. Importing a Word Document to Excel Try It Lesson 31: Working with Outlook from Excel Opening Outlook Composing an E-mail in Outlook from Excel Putting It All Together E-mailing a Single Worksheet