Page 9 - Microsoft Office Excel 2003 Programming Inside Out
P. 9

Table of Contents

                                  Writing to the Screen and Accepting Input  . . . . . . . . . . . . . . . . . . . . . . . . 67
                                       Creating a Message Box . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
                                       Creating an Input Box . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
                                  Defining Object Variables  . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
                                  Creating Custom Data Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
                                       With...End With Command  . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
                                  Controlling Program Flow. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
                                       Selection Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74
                                       Loops . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
                                       GoTo Statement  . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .82
                                  Error Handling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
                             Chapter 5
                             Creating Sub and Function Procedures                                  85

                                  Defining Sub Procedures. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
                                       Defining the Scope of a Sub Procedure  . . . . . . . . . . . . . . . . . . . . . . 90
                                       Running a Sub Procedure from Within Another Procedure  . . . . . . . . . 93
                                       Retaining Values Between Procedure Calls. . . . . . . . . . . . . . . . . . . . 98
                                  Defining Function Procedures  . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
                                       Creating a Function Procedure. . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
                                       Running Function Procedures  . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
                                       Passing Arguments to Procedures . . . . . . . . . . . . . . . . . . . . . . . . . 101
                                       Passing Named Arguments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
                                  Organizing for Success . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104

                    Part 3
                    The Excel Object Model

                             Chapter 6
                             The Application Object                                              107

                                  Introducing the Application Object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
                                       Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
                                       Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119
                             Chapter 7
                             Workbooks and Worksheets                                            129

                                  The Workbooks Collection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129
                                       Creating New Workbooks  . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129
                                       Opening Workbooks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130
                                       Workbook Properties  . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138
                                       Workbook Methods  . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145
                                       Printing and Previewing Workbooks  . . . . . . . . . . . . . . . . . . . . . . . . 147





                                                                                                         ix
   4   5   6   7   8   9   10   11   12   13   14