Opened 13 years ago
Closed 12 years ago
#2163 closed Bug (Fixed)
_ExcelBookClose dont work correctly on _ExcelBookAttach on more than one opened wokdbook
Reported by: | bogQ | Owned by: | water |
---|---|---|---|
Milestone: | 3.3.9.5 | Component: | Standard UDFs |
Version: | 3.3.9.2 | Severity: | None |
Keywords: | Cc: |
Description
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
Attachments (0)
Change History (3)
comment:1 Changed 13 years ago by bogQ
comment:2 Changed 13 years ago by trancexx
- Component changed from AutoIt to Standard UDFs
comment:3 Changed 12 years ago by water
- Milestone set to 3.3.9.5
- Owner set to water
- Resolution set to Fixed
- Status changed from new to closed
Fixed by revision [7289] in version: 3.3.9.5
Guidelines for posting comments:
- You cannot re-open a ticket but you may still leave a comment if you have additional information to add.
- In-depth discussions should take place on the forum.
For more information see the full version of the ticket guidelines here.
tested problem on other comp under XP SP3 under Excel 2007, identical results