Jump to content

This site uses cookies. By continuing to browse the site you are agreeing to our use of cookies. Find out more here. X
X


Photo

_ExcelBookClose: Hanging Process


  • Please log in to reply
11 replies to this topic

#1 Cedri

Cedri

    Seeker

  • Active Members
  • 11 posts

Posted 18 July 2012 - 04:18 PM

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 http://www.autoitscript.com/forum/topic/34302-yet-another-excelcom-udf/

#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, 19 July 2012 - 04:01 PM.








#2 JLogan3o13

JLogan3o13

    115 and holding

  • MVPs
  • 3,862 posts

Posted 18 July 2012 - 04:24 PM

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?

Programming is like sex...one mistake and you have to support it for a lifetime.

My Scripts:Include Source with Compiled Script, Disk Maintenance for Windows XP, "Deal-A-Day" Sites, Windows Firewall UDF


#3 Cedri

Cedri

    Seeker

  • Active Members
  • 11 posts

Posted 18 July 2012 - 04:40 PM

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.

#4 JLogan3o13

JLogan3o13

    115 and holding

  • MVPs
  • 3,862 posts

Posted 18 July 2012 - 04:44 PM

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

Programming is like sex...one mistake and you have to support it for a lifetime.

My Scripts:Include Source with Compiled Script, Disk Maintenance for Windows XP, "Deal-A-Day" Sites, Windows Firewall UDF


#5 BrewManNH

BrewManNH

    באָבקעס מיט קודוצ׳ה

  • MVPs
  • 10,027 posts

Posted 18 July 2012 - 04:45 PM

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 an XP machine, 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!

 

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 editorGUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.
GUIToolTip UDF Demo - Demo script to show how to use the GUIToolTip UDF to create and use customized tooltips. Latin Square password generator

 

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.


#6 bogQ

bogQ

    For me, it’s simple - it’s a way of life.

  • Active Members
  • PipPipPipPipPipPip
  • 1,820 posts

Posted 18 July 2012 - 05:39 PM

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, 18 July 2012 - 05:45 PM.

TCP server and client - Learning about TCP servers and clients connection
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.

 


#7 Reg2Post

Reg2Post

    Wayfarer

  • Active Members
  • Pip
  • 84 posts

Posted 18 July 2012 - 05:57 PM

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, 18 July 2012 - 06:04 PM.


#8 Cedri

Cedri

    Seeker

  • Active Members
  • 11 posts

Posted 18 July 2012 - 08:29 PM

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.

#9 Cedri

Cedri

    Seeker

  • Active Members
  • 11 posts

Posted 18 July 2012 - 08:51 PM

Updated list of things I have tried.

#10 JLogan3o13

JLogan3o13

    115 and holding

  • MVPs
  • 3,862 posts

Posted 18 July 2012 - 09:10 PM

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.

Programming is like sex...one mistake and you have to support it for a lifetime.

My Scripts:Include Source with Compiled Script, Disk Maintenance for Windows XP, "Deal-A-Day" Sites, Windows Firewall UDF


#11 Cedri

Cedri

    Seeker

  • Active Members
  • 11 posts

Posted 18 July 2012 - 09:35 PM

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.

#12 Cedri

Cedri

    Seeker

  • Active Members
  • 11 posts

Posted 19 July 2012 - 04:00 PM

This was fixed by a reinstall and updating *includeExcel.au3 with http://www.autoitscript.com/forum/topic/34302-yet-another-excelcom-udf/




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users