From: http://www.excelba.com/Art/Html/290.html
The following content can be found in the help of Excel VBA. The purpose of this article is to make it easy for users who come here to find the SQL connection to an Excel file, these articles may be added in the VBA tutorial section of Excel recently to put the same or similar things together for horizontal comparison.
Workbooks object open method: used to open a workbook. Its syntax is:
Expression. Open (filename, updatelinks, readonly, format, password, writerespassword, ignorereadonlyrecommended, origin, delimiter, editable, y, converter, addtomru, local, corruptload)
Where:
Expression is required. This expression returns a workbooks object.
Filename string type, required. The name of the workbook to open.
Updatelinks variant type. Optional. Specifies the update method of the link in the file. If this parameter is omitted, the system prompts you to select the link update method. Otherwise, the value of this parameter should be a value in the following table.
Value Meaning
0. No reference is updated.
1. Update external references without updating remote references.
2. Update remote references without updating external references.
3. Update both remote reference and external reference.
Readonly variant type. Optional. If this value is true, the workbook is opened in read-only mode.
Format variant type. Optional. If Microsoft Excel is opening a text file, this parameter is used to specify the delimiter, as shown in the following table. If this parameter is omitted, the current Delimiter is used.
Value Separator
1 Tab
2 comma
3 Spaces
4 semicolon
5 No Separator
6. Custom characters (see delimiter parameters)
Password variant type. Optional. This string specifies the password to open a protected workbook. If this parameter is omitted and a password is set for the workbook, the user is prompted to enter the password.
Writerespassword variant type. Optional. This string is the write authorization password for a write protection workbook. If this parameter is omitted and a password is set for the workbook, the user is prompted to enter the password.
Ignorereadonlyrecommended variant type. Optional. If this value is true, Microsoft Excel does not display recommended read-only messages (if the workbook is saved with the "Recommended read-only" option ).
Origin variant type. Optional. If the file is a text file, this parameter is used to indicate the operating system of the file (to correctly map the code page and press enter/line feed (CR/LF )). Can be one of the following xlplatform constants: xlmacintosh, xlwindows, or xlmsdos. If this parameter is omitted, the current operating system is used.
Optional, delimiter variant type. If the file is a text file and the format parameter is 6, this parameter is used to specify Characters Used as separators. For example, you can use CHR (9) to represent a tab, "," to represent a comma, and ";" to represent a semicolon or a custom character. If this parameter is a string, only the first character of the string is used.
Editable variant type. Optional. If the file is Microsoft Excel 4.0, when the value of this parameter is true, the macro can be opened for display in the window. If the value of this parameter is false or this parameter is omitted, the loaded macro is opened in a hidden mode and cannot be set as visible. This option cannot be used to load macros created by Microsoft Excel 5.0 or later. If the file is an Excel template, when the parameter value is true, the specified template is opened for editing. When the parameter is false, you can open a new workbook Based on the specified template. The default value is false.
Optional. Y variant type. When the file cannot be opened in read/write mode, if the value of this parameter is true, you can add the file to the file notification list. Microsoft Excel opens the file in read-only mode and polls the file notification list. It notifies you when the file in the file notification list is available. If the value of this parameter is false or this parameter is omitted, no notification is requested and no unavailable files can be opened.
Converter variant type. Optional. The index number of the first file converter used to open the file. First, use the specified file converter: If the converter cannot recognize this file, try all the converters. The converter index number consists of the converter row numbers returned by the fileconverters attribute.
(Optional) addtomru variant type. If the value is true, the workbook is added to the list of recently used files. The default value is false.
Local variant type. Optional. If the value is true, the file is saved in Microsoft Excel (including the control panel settings. If the value is false (default value), save the file in the language of Visual Basic for Applications (VBA), where Visual Basic for Applications (VBA) is a typical American English version installed, unless the workbooks. open from the old international xl5/95 VBA project.
Corruptload variant type. Optional. It can be one of the following constants: xlnormalload, xlrepairfile, and xlextractdata. If no value is specified, the default value is normal, but if Excel has tried to open the file, it can be in the secure loading or data recovery status. The preferred value is normal. If an Excel file is stopped when it is opened, it is in the safe loading status. If Excel stops again, the data is restored.
Example
In this example, open the analysis.xls workbook and run the auto_open macro.
Workbooks. Open "analysis. xls"
It seems that there are many parameters in the open method. In fact, there are not many parameters often used. In addition to the required filename, the most common one is password, which is used to open an Excel file containing the opened permission password, the following example shows how to enable analysis with the password "123. xls file:
Workbooks. Open "analysis. xls", password: = "123"