Sign in to follow this  
Followers 0

_ExcelBookClose: Hanging Process

12 posts in this topic

Posted (edited)

Windows Version: Windows 7 Enterprise

Excel Version: 2007

I'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 _excelbookclose

Updating 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 by Cedri

Share this post


Link to post
Share on other sites



Posted

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?

Share this post


Link to post
Share on other sites

Posted

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.

Share this post


Link to post
Share on other sites

Posted

What about changing your _ExcelBookNew(0) to _ExcelBookNew(1) so its visible?

Share this post


Link to post
Share on other sites

Posted

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.

Share this post


Link to post
Share on other sites

Posted (edited)

Ticket #2163

see if this helps

the code is workaround for more that one excel opened bug and shud solwe hanging bug along with it on more that 1 opened

or just try adding

$oExcel = ''

after you call command to close excel if your using only one

Edited by bogQ

Share this post


Link to post
Share on other sites

Posted (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 by Reg2Post

Share this post


Link to post
Share on other sites

Posted

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.

Share this post


Link to post
Share on other sites

Posted

Updated list of things I have tried.

Share this post


Link to post
Share on other sites

Posted

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.

Share this post


Link to post
Share on other sites

Posted

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.

Share this post


Link to post
Share on other sites

Posted

This was fixed by a reinstall and updating *includeExcel.au3 with

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0