﻿id	summary	reporter	owner	description	type	status	milestone	component	version	severity	resolution	keywords	cc
2163	_ExcelBookClose dont work correctly on _ExcelBookAttach on more than one opened wokdbook	bogQ	water	"tested on XP SP3 under Excel 2002
Short script
{{{
#include <Excel.au3>

$oExcel1 = _ExcelBookAttach(""aBook1.xls"",""Filename"")
$oExcel2 = _ExcelBookAttach(""bBook1.xls"",""Filename"")
_ExcelBookClose($oExcel1, 0, 0)
}}}
the identical bug is with one _ExcelBookAttach while there are 2 excel workbooks already opened

problem related with:
1) Application.DisplayAlerts
2) Application.ScreenUpdating
on trying to update object after object is closed

On stabile relise, excel window stop rendering picture and Scite displays following error
{{{
C:\Program Files\AutoIt3\Include\Excel.au3 (410) : ==> The requested action with this object has failed.:
$oExcel.Application.DisplayAlerts = $fDisplayAlerts
$oExcel.Application^ ERROR
}}}
On beta it don't have error but the excel book that is still opened dont get any rendering

Changes (additional lines) that can probbaby fix problem on func _ExcelBookClose are marked with ;<<<

{{{
Func _ExcelBookClose($oExcel, $fSave = 1, $fAlerts = 0)
    If Not IsObj($oExcel) Then Return SetError(1, 0, 0)
	
    Local $sObjName = ObjName($oExcel)
	
    If $fSave > 1 Then $fSave = 1
    If $fSave < 0 Then $fSave = 0
    If $fAlerts > 1 Then $fAlerts = 1
    If $fAlerts < 0 Then $fAlerts = 0
	
    ; Save the users specified settings
    Local $fDisplayAlerts = $oExcel.Application.DisplayAlerts
    Local $fScreenUpdating = $oExcel.Application.ScreenUpdating
    ; Make necessary changes
    $oExcel.Application.DisplayAlerts = $fAlerts
    $oExcel.Application.ScreenUpdating = $fAlerts
	
    Switch $sObjName
        Case ""_Workbook""
            If $fSave Then $oExcel.Save()
            ; Check if multiple workbooks are open
            ; Do not close application if there are
            If $oExcel.Application.Workbooks.Count > 1 Then
                $oExcel.Close()
                $oExcel = '';                             <<< fully clean closed object
                $oExcel = ObjGet("""", ""Excel.Application"");<<< re attach to other already opened Workbooks so that DisplayAlerts and ScreenUpdating can be applied correctly
                ; Restore the users specified settings
                $oExcel.Application.DisplayAlerts = $fDisplayAlerts
                $oExcel.Application.ScreenUpdating = $fScreenUpdating
                $oExcel = '';                             <<< fully clean unnedded object
            Else
                $oExcel.Application.Quit
            EndIf
        Case ""_Application""
            If $fSave Then $oExcel.ActiveWorkBook.Save()
            $oExcel.Quit()
        Case Else
            Return SetError(1, 0, 0)
    EndSwitch
    Return 1
EndFunc   ;==>_ExcelBookClose
}}}"	Bug	closed	3.3.9.5	Standard UDFs	3.3.9.2	None	Fixed		
