Jump to content

Excel created by AutoIt does not fully quit


jnash67
 Share

Recommended Posts

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?

Link to comment
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!"

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

Link to comment
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 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

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
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...