Cedri Posted July 18, 2012 Posted July 18, 2012 (edited) Windows Version: Windows 7 EnterpriseExcel Version: 2007I'm digging up a bit of an old issue since the only occurrence of this I can find related to the forums was back in 2009. The problem is as follows:When using the command: _ExcelBookOpen($filepath, 0), the command _ExcelBookClose($oExcel) does not end the Excel Process and with multiple uses of _ExcelBookOpen multiple processes are opened and does not close even when the program terminates. What I want to accomplish is saving this book, closing it, ending the process without the use of "ProcessClose". If another Excel window exists, I would like it to remain open.Things I have tried:$oExcel.Quit$oExcel.Application.Quit$oExcel ''sleep(3000) before _excelbookcloseUpdating to Beta*****RESOLVED*****This was fixed by a reinstall and updating *includeExcel.au3 with #include <Excel.au3> $oExcel = _ExcelBookNew(0) _ExcelWriteCell($oExcel, "Some text", 3, 2) _ExcelBookSaveAs($oExcel, @DesktopDir & "Test.xls", "xls", 0, 1) _ExcelBookClose($oExcel) Edited July 19, 2012 by Cedri
Moderators JLogan3o13 Posted July 18, 2012 Moderators Posted July 18, 2012 Hi, Cedri. Unfortunately, I have run your script a dozen times in the same environment you show, and have been unable to get it to fail to close Excel. Maybe add in a short sleep before you call _ExcelBookClose? "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum!
Cedri Posted July 18, 2012 Author Posted July 18, 2012 I just tried that. The process remains open in Task Manager. If I open the book I just created i am unable to see the data and then subsequently close it, the process exits and then I am able to read the file normally. It's as though the program closes the book but does not exit.
Moderators JLogan3o13 Posted July 18, 2012 Moderators Posted July 18, 2012 What about changing your _ExcelBookNew(0) to _ExcelBookNew(1) so its visible? "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum!
BrewManNH Posted July 18, 2012 Posted July 18, 2012 I just ran this using Excel 2010 on Windows 7 Enterprise, and Excel 2007 on XP Professional and neither one left Excel open after it terminated. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator
bogQ Posted July 18, 2012 Posted July 18, 2012 (edited) Ticket #2163see if this helpsthe code is workaround for more that one excel opened bug and shud solwe hanging bug along with it on more that 1 openedor just try adding$oExcel = ''after you call command to close excel if your using only one Edited July 18, 2012 by bogQ TCP server and client - Learning about TCP servers and clients connectionAu3 oIrrlicht - Irrlicht projectAu3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related) There are those that believe that the perfect heist lies in the preparation.Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.
Reg2Post Posted July 18, 2012 Posted July 18, 2012 (edited) The only way I was able to reproduce this issue was to run the example script with an instance of Excel running in the background (hidden but in the task manager). You may have an instance from your testing that did not close properly, possibly from some other scripts that is opening other instances, as was mentioned.Comb through your other scripts that open Excel instances and check that they are all closing out properly.Are you getting any console messages if you run the scripts before compiling?Edit: Are you opening new workbooks and re-assigning them all to the same Excel Object ($oExcel)? And then trying to close them after multiple instances have be created? Edited July 18, 2012 by Reg2Post
Cedri Posted July 18, 2012 Author Posted July 18, 2012 No other scripts are open when I'm running this. The example script above is the only one running when this little bug happens. I attempted to add in $oExcel = '' to no avail.
Moderators JLogan3o13 Posted July 18, 2012 Moderators Posted July 18, 2012 Just for grins, try adding something like this to the end of your script: For $i = 1 to 10 _ExcelBookClose($oExcel) Sleep(5000) Next I can't help but wonder if it is lagging for some reason. "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum!
Cedri Posted July 18, 2012 Author Posted July 18, 2012 Even with the multiple instances, it still leaves Excel.exe active. This could be my install. I'm going to try coding it on another PC when i get off work here. Will report back tomorrow. Thank you all for you time today.
Cedri Posted July 19, 2012 Author Posted July 19, 2012 This was fixed by a reinstall and updating *includeExcel.au3 with
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