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

Part 3:  The Excel Object Model
                                        Microsoft Office Excel 2003 Programming Inside Out

                    Opening Workbooks
                             After you’ve created one or more workbooks, you’ll probably want to open them at some point
                             with the Workbooks collection’s Open method, which, in its simplest form, appears as follows:
             Chapter 7
                             Workbooks.Open  (FileName:="MonthlySales.xls")
                             You do have plenty more options when you open a workbook, however. The Open method has
                             the following full syntax:
                             expression.Open(FileName,  UpdateLinks,  ReadOnly,  Format,Password,WriteResPassword,
                             IgnoreReadOnlyRecommended,  Origin,  Delimiter,  Editable,  Notify,
                             Converter,AddToMru,  Local,  CorruptLoad)
                             Table 7-1 describes the parameters available for use with the Workbooks.Open method. Of par­
                             ticular interest are the ReadOnly parameter, which requires that the user running your macro
                             open the workbook in read-only mode; the Password parameter, which need only be set if the
                             workbook is password protected; and the Delimiter parameter, which specifies the character
                             used to separate fields if the file the user is opening is a text file.


                             Note  You’ll learn more about opening text files later in this section.

                             Table 7-1.  The Parameters Associated with the Workbooks.Open
                             Method
                             Parameter           Description
                             FileName            Required string specifying the name and path of the file to open.
                             UpdateLinks	        Tells Excel how to handle any links from the workbook to other
                                                 workbooks. 0 means no updates, 1 means update external
                                                 references, 2 means update remote references, and 3 means
                                                 update both external and remote references.
                             ReadOnly            When set to True, opens the workbook in read-only mode.
                             Password	           A string that contains the password required to open the workbook.
                                                 If you omit the argument, the regular Excel password protection
                                                 routine will take over.
                             WriteResPassword	   A string that contains the password required to write to a write-
                                                 reserved workbook. If you omit the argument, the regular Excel
                                                 password protection routine will take over.
                             IgnoreReadOnly      If the workbook was saved with the Read-Only Recommended option
                             Recommended	        turned on, setting this parameter to True causes Excel to skip
                                                 showing the Read-Only Recommended message box when the
                                                 workbook is opened.
                             Origin              Indicates the operating system used to create the file. The three
                                                 constants are xlWindows, xlMacintosh, and xlMSDOS. If this
                                                 parameter isn’t specified, Excel uses the current operating system.

                130
   151   152   153   154   155   156   157   158   159   160   161