Share via


Workbooks.Open Method

Opens a workbook.

Namespace:  Microsoft.Office.Interop.Excel
Assembly:  Microsoft.Office.Interop.Excel (in Microsoft.Office.Interop.Excel.dll)

Syntax

'Declaration
Function Open ( _
    Filename As String, _
    UpdateLinks As Object, _
    ReadOnly As Object, _
    Format As Object, _
    Password As Object, _
    WriteResPassword As Object, _
    IgnoreReadOnlyRecommended As Object, _
    Origin As Object, _
    Delimiter As Object, _
    Editable As Object, _
    Notify As Object, _
    Converter As Object, _
    AddToMru As Object, _
    Local As Object, _
    CorruptLoad As Object _
) As Workbook
'Usage
Dim instance As Workbooks
Dim Filename As String
Dim UpdateLinks As Object
Dim ReadOnly As Object
Dim Format As Object
Dim Password As Object
Dim WriteResPassword As Object
Dim IgnoreReadOnlyRecommended As Object
Dim Origin As Object
Dim Delimiter As Object
Dim Editable As Object
Dim Notify As Object
Dim Converter As Object
Dim AddToMru As Object
Dim Local As Object
Dim CorruptLoad As Object
Dim returnValue As Workbook

returnValue = instance.Open(Filename, _
    UpdateLinks, ReadOnly, Format, Password, _
    WriteResPassword, IgnoreReadOnlyRecommended, _
    Origin, Delimiter, Editable, Notify, _
    Converter, AddToMru, Local, CorruptLoad)
Workbook Open(
    string Filename,
    Object UpdateLinks,
    Object ReadOnly,
    Object Format,
    Object Password,
    Object WriteResPassword,
    Object IgnoreReadOnlyRecommended,
    Object Origin,
    Object Delimiter,
    Object Editable,
    Object Notify,
    Object Converter,
    Object AddToMru,
    Object Local,
    Object CorruptLoad
)

Parameters

  • Filename
    Type: System.String

    Required String. The file name of the workbook to be opened.

  • UpdateLinks
    Type: System.Object

    Optional Object. Specifies the way links in the file are updated. If this argument is omitted, the user is prompted to specify how links will be updated. Otherwise, this argument is one of the values listed in the following table.

    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
    Type: System.Object

    Optional Object. True to open the workbook in read-only mode.

  • Format
    Type: System.Object

    Optional Object. 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.

  • Password
    Type: System.Object

    Optional Object. A string that contains the password required to open a protected workbook. If this argument is omitted and the workbook requires a password, the user is prompted for the password.

  • WriteResPassword
    Type: System.Object

    Optional Object. A string that contains the password required to write to a write-reserved workbook. If this argument is omitted and the workbook requires a password, the user will be prompted for the password.

  • IgnoreReadOnlyRecommended
    Type: System.Object

    Optional Object. True to have Microsoft Excel not display the read-only recommended message (if the workbook was saved with the Read-Only Recommended option).

  • Origin
    Type: System.Object

    Optional Object. If the file is a text file, this argument indicates where it originated (so that code pages and Carriage Return/Line Feed (CR/LF) can be mapped correctly). Can be one of the following XlPlatform constants: xlMacintosh, xlWindows, or xlMSDOS. If this argument is omitted, the current operating system is used.

  • Delimiter
    Type: System.Object

    Optional Object. If the file is a text file and the Format argument is 6, this argument is a string that specifies the character to be used as the delimiter. For example, use Chr(9) for tabs, use "," for commas, use ";" for semicolons, or use a custom character. Only the first character of the string is used.

  • Editable
    Type: System.Object

    Optional Object. If the file is a Microsoft Excel 4.0 add-in, this argument is True to open the add-in so that it’s a visible window. If this argument is False or omitted, the add-in is opened as hidden, and it cannot be unhidden. This option doesn't apply to add-ins created in Microsoft Excel 5.0 or later. If the file is an Excel template, use True to open the specified template for editing or False to open a new workbook based on the specified template. The default value is False.

  • Notify
    Type: System.Object

    Optional Object. If the file cannot be opened in read/write mode, this argument is True to add the file to the file notification list. Microsoft Excel will open the file as 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 any attempts to open an unavailable file will fail.

  • Converter
    Type: System.Object

    Optional Object. The index of the first file converter to try when opening the file. The specified file converter is tried first; if this converter doesn’t recognize the file, all other converters are tried. The converter index consists of the row numbers of the converters returned by the FileConverters property.

  • AddToMru
    Type: System.Object

    Optional Object. True to add this workbook to the list of recently used files. The default value is False.

  • Local
    Type: System.Object

    Optional Object. True saves files against the language of Microsoft Excel (including control panel settings). False (default) saves files against the language of Visual Basic for Applications (VBA) (which is typically U.S. English unless the VBA project where Workbooks.Open is run from is an old internationalized XL5/95 VBA project).

  • CorruptLoad
    Type: System.Object

    Optional Object. Can be one of the following constants: xlNormalLoad, xlRepairFile, and xlExtractData. The default behavior if no value is specified is usually normal, but may be safe load or data recovery if Excel has already attempted to open the file. The first attempt is normal. If Excel stops operating while opening the file, the second attempt is safe load. If Excel again stops operating, the next attempt is data recovery.

Return Value

Type: Microsoft.Office.Interop.Excel.Workbook

Remarks

By default, macros are enabled when opening files programmatically. Use the AutomationSecurity property to set the macro security mode used when opening files programmatically.

See Also

Reference

Workbooks Interface

Workbooks Members

Microsoft.Office.Interop.Excel Namespace