rosaz Posted April 20, 2010 Share Posted April 20, 2010 Hello, I'm having trouble with what I know should be a basic bit of code, but which is proving difficult! The _ExcelBookClose command just isn't working... after running the script (below) the Excel spreadsheet window will just sit there, and not respond to anything until I have to manually close it. It seems almost like instead of closing it, the command just turns off screen updating for it but that doesn't make any sense... Anyways, here's my code, please help!!! [/code]#include <Excel.au3> $excel = _ExcelBookNew(1) _ExcelBookClose($excel)[code] Link to comment Share on other sites More sharing options...
MrMitchell Posted April 20, 2010 Share Posted April 20, 2010 (edited) What is the Return value and @error of the _ExcelBookClose() function? May as well get the same for _ExcelBookNew() as well... Edited April 20, 2010 by MrMitchell Link to comment Share on other sites More sharing options...
rosaz Posted April 20, 2010 Author Share Posted April 20, 2010 I'm still a newbie so I'm not sure how to get the return value on _ExcelBookClose, it's been giving me an error when I try to put something in front of it like: $retval = _ExcelBookClose($excel) But the @error is 1 (no object) even though when I do IsObj($excel) before the _ExcelBookClose command, it returns 1. Very puzzling. Link to comment Share on other sites More sharing options...
MrMitchell Posted April 20, 2010 Share Posted April 20, 2010 Well dunno what to tell ya... I ran this: #include <Excel.au3> $excel = _ExcelBookNew(1) $retval = _ExcelBookClose($excel) $error = @error ConsoleWrite("Return value of ExcelBookClose($excel) = " & $retval & " and $error = " & $error & @CRLF) and got this: Return value of ExcelBookClose($excel) = 1 and $error = 0 Were there other processes of Excel.exe running whether or not their windows were visible? Link to comment Share on other sites More sharing options...
water Posted August 6, 2010 Share Posted August 6, 2010 (edited) I'm a bit late but I have run into the same problem: Your example script (posting #1) runs fine on my Windows XP SP2 machine with Office XP. But it doesn't work on Windows 7 with Excel 2010. The problem is that Office XP returns the ObjName as "_Application" and Excel 2010 returns nothing. _ExcelBookClose checks for "_Application" and "_Workbook" and therefore sets @error to 1 as $sobName is blank. This seems to be a problem with Excel because the example script for ObjName displays the object name for IE identical on XP and Windows 7. I will open a new thread and see if it's an AutoIt or Excel bug. Edited August 6, 2010 by water My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now