# Function Reference

# _Excel_Open

Connects to an existing Excel instance or creates a new one

#include <Excel.au3>
_Excel_Open ( [$bVisible = True [, $bDisplayAlerts = False [, $bScreenUpdating = True [, $bInteractive = True [, $bForceNew = False]]]]] )

## Parameters

$bVisible | [optional] True specifies that the application will be visible (default = True)
$bDisplayAlerts | [optional] False suppresses all prompts and alert messages while opening a workbook (default = False)
$bScreenUpdating | [optional] False suppresses screen updating to speed up your script (default = True)
$bInteractive | [optional] If False, Excel blocks all keyboard and mouse input by the user (except input to dialog boxes) (default = True)
$bForceNew | [optional] True forces to create a new Excel instance even if there is already a running instance (default = False)

## Return Value

Success: | the Excel application object. Sets @extended to: 0 - Excel was already running 1 - Excel was not running or $bForceNew was set to True. A new Excel instance has been created
Failure: | 0 and sets @error.
@error: | 1 - Error returned by ObjCreate. @extended is set to the COM error code.

## Remarks

If $bDisplayAlerts is set to False and a message requires a response, Excel chooses the default response.
To enhance performance set $bScreenUpdating to False. The screen will not be updated until you set it back to true ($oExcel.ScreenUpdating = True).
Blocking user input ($bInteractive = False) will prevent the user from interfering with the AutoIt script.
If set to False, don't forget to set it back to True ($oExcel.Interactive = True)

## Related

_Excel_Close

## Example

### Example 1

    #include <Excel.au3>
    #include <MsgBoxConstants.au3>

    ; Create application object or connect to an already running Excel instance
    Local $oExcel = _Excel_Open()
    If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_Open Example 1", "Error creating the Excel application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
    MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_Open Example 1", "Excel Application has been opened successfully." & @CRLF & @CRLF & "Will _Excel_Close close the application?: " & @extended)

### Example 2

    #include <Excel.au3>
    #include <MsgBoxConstants.au3>

    ; Force the creation of a new Excel application and display alerts
    _Excel_Open(Default, Default, Default, Default, True)
    If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_Open Example 2", "Error creating a new Excel application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
    Local $aProcesses = ProcessList("Excel.exe")
    If $aProcesses[0][0] = 1 Then
        MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_Open Example 2", "Excel Application has been opened successfully." & @CRLF & @CRLF & $aProcesses[0][0] & " Excel instance is running.")
    Else
        MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_Open Example 2", "Excel Application has been opened successfully." & @CRLF & @CRLF & $aProcesses[0][0] & " Excel instances are running.")
    EndIf