Applies To
Workbooks Collection.
Description
Opens a workbook.
Syntax
object.Open(fileName, updateLinks, readOnly, format, password, writeResPassword, ignoreReadOnlyRecommended, origin, delimiter, editable, notify, converter)
object
Required. The Workbooks object.
fileName
Required. Specifies the filename of the workbook to open.
updateLinks
Optional. Specifies how links in the file are updated. If this argument is omitted, the user is prompted to determine how to update links. Otherwise, this argument is one of the values shown in the following table.
Value
Meaning
0
No updates
1
Updates external but not remote references
2
Updates remote but not external references
3
Updates both remote and external references
If Microsoft Excel is opening a file in the WKS, WK1, or WK3 format and the updateLinks argument is 2, Microsoft Excel generates charts from the graphs attached to the file. If the argument is 0, no charts are created.
readOnly
Optional. If True, the workbook is opened in read-only mode.
format
Optional. If Microsoft Excel is opening a text file, this argument specifies the delimiter character, as shown in the following table. If this argument is omitted, the current delimiter is used.
Value
Delimiter
1
Tabs
2
Commas
3
Spaces
4
Semicolons
5
Nothing
6
Custom character, see the delimiter argument.
password
Optional. A string containing the password required to open a protected workbook. If omitted and the workbook requires a password, the user is prompted for the password.
writeResPassword
Optional. A string containing the password required to write to a write-reserved workbook. If omitted and the workbook requires a password, the user will be prompted for the password.
ignoreReadOnlyRecommended
Optional. If True and the workbook was saved with the Read-Only Recommended option, Microsoft Excel does not display the read-only recommended message.
origin
Optional. If the file is a text file, this indicates where it originated (so that code pages and CR/LF can be mapped correctly). May be one of xlMacintosh, xlWindows, or xlMSDOS. If this argument is omitted, the current operating system is used.
delimiter
Optional. If the file is a text file and the format argument is 6, this is a string that specifies the character to use as the delimiter. For example, Chr(9) for tabs, "," for commas, ";" for semicolons, or a custom character. Only the first character of the string is used.
editable
Optional. If the file is a Microsoft Excel 4.0 add-in, using True opens the add-in so that it is a visible window. If False or omitted, the add-in is opened hidden and it cannot be unhidden. This option does not apply for add-ins created in Microsoft Excel 5.0 or later. If the file is not an add-in, specifying True prevents the running of any Auto_Open macros.
notify
Optional. If the file cannot be opened in the read-write mode, specifying True adds the file to the file notification list. Microsoft Excel will open the file read-only, poll the file notification list, and then notify the user when the file becomes available. If this argument is False or omitted, no notification is requested, and attempts to open an unavailable file will fail.
converter
Optional. Specifies the index of the first file converter to try when opening the file. The specified file converter is tried first, then all other converters are tried if the specified converter does not recognize the file. The converter index is the row number of the converters returned by the FileConverters property.
Remarks
If the workbook being opened has any Auto_Open macros in it, they will not be run when you open the file from Visual Basic. If you want to run the Auto_Open macro, you must use the RunAutoMacros method.
See Also
Activate Method, Close Method, FileConverters Property, OpenText Method.
Example
This example opens the workbook ANALYSIS.XLS and then runs its Auto_Open macro.
Workbooks.Open "ANALYSIS.XLS" ActiveWorkbook.RunAutoMacros xlAutoOpen