Jump to content

_ExcelBookClose: Hanging Process


Recommended Posts

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
Link to comment
Share on other sites

  • Moderators

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!

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 Gude
How 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

Link to comment
Share on other sites

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

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
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.

 
Link to comment
Share on other sites

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
Link to comment
Share on other sites

  • Moderators

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!

Link to comment
Share on other sites

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.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...