Sign in to follow this  
Followers 0
jnash67

Excel created by AutoIt does not fully quit

8 posts in this topic

I am creating an excel instance and waiting for it to close. However, when the excel quits through either the file menu or through an application.quit VBA call, the window disappears but it doesn't really die. In the following code I never get to the msgbox until I actually kill the process with process manager.

Local $oe = _ExcelBookNew()
$oe.caption = "123"
WinWaitClose("123")
MsgBox(0, "bye", "bye")
Exit

I haven't found any way to get Excel to actually fully die. How can I get this to happen?

Share this post


Link to post
Share on other sites



You might be better off with

ProcessWaitClose()


George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites

Check those out:

$oExcel.Workbooks.Close

$oExcel.Application.Quit

Share this post


Link to post
Share on other sites

Check those out:

$oExcel.Workbooks.Close

$oExcel.Application.Quit

ProcessWaitClose has the same problem as WinWaitClose. It's not closing -- neither the window or the process. So the below code never gets to the Msgbox either:

Local $oe = _ExcelBookNew()
$oe.caption = "123"
Local $oep = WinGetProcess("123")
ProcessWaitClose($oep)
MsgBox(0, "bye", "bye")
Exit

For $oExcel.Workbooks.Close and $oExcel.Application.Quit, I know I can kill Excel from AutoIt. The issue is, I need AutoIt to wait until the user kills Excel. However, even when the user kills Excel, it doesn't really die. The window and process are still there in some form or another, although the excel window in the UI seems to have disappeared.

Share this post


Link to post
Share on other sites

I had a similar problem when running the 32 bit version of Office on a 64 bit operating system (Windows 7) and executing/compiling the script for 64 bit.

When compiling the script for 32 bit everything was running fine again.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

The solution to this issue is for AutoIt to release the object variable as follows:

Local $oe = _ExcelBookNew() 
$oe.caption = "123" 
$oe = 0 ; this releases the object
WinWaitClose("123") 
MsgBox(0, "bye", "bye") 
Exit

If you store the HWND or PID before releasing (with WinGetHandle or WinGetProcess), you can retrieve the object using WinAPI functions like _WinAPI_Getwindow.

I would still consider this a "bug" because the AutoIt documentation says you no longer need to release objects (although this is in reference to memory management).

Edited by jnash67

Share this post


Link to post
Share on other sites

I had a similar problem when running the 32 bit version of Office on a 64 bit operating system (Windows 7) and executing/compiling the script for 64 bit.

When compiling the script for 32 bit everything was running fine again.

Everything I did was in a 32-bit environment

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