BigDaddyO

Aut2Exe has stopped working "on a compiled script"?

5 posts in this topic

#1 ·  Posted

I have a script that connects to a database, retrieves data, then uses the _Excel UDF functions to build excel reports with that data.

The script works fine when running uncompiled from Scite, but after compiling it and running the .exe it will crash with (Aut2Exe has stopped working) which is weird since I thought that was just used to compile the scripts.  Also, it doesn't crash right away but after the script has been running for a random amount of time.  Sometimes I'll get 3 of the 6 reports, sometimes i'll only get 1 before it crashes.

Iv'e never encountered this type of problem so I'm not sure where to start to fix it.

 

Thanks,

Mike


Share this post


Link to post
Share on other sites



#3 ·  Posted

The only DLL calls are in the Reduce Memory function that I have been using for years.  I commented it out, and got all the way to the last report before it got the same error.  

Every time it crashes, Excel is left open in the background so it must have something to do with Excel.  I'm going to update so Excel displays what it's doing while running and see what's going on when it crashes.

 

;------------------------------------------------------------------
; Reduce memory usage
; Author wOuter ( mostly )
;------------------------------------------------------------------
Func _ReduceMemory($i_PID = -1)
    If $i_PID <> -1 Then
        Local $ai_Handle = DllCall("kernel32.dll", 'int', 'OpenProcess', 'int', 0x1f0fff, 'int', False, 'int', $i_PID)
        Local $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', $ai_Handle[0])
        DllCall('kernel32.dll', 'int', 'CloseHandle', 'int', $ai_Handle[0])
    Else
        Local $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', -1)
    EndIf
    Return $ai_Return[0]
EndFunc;==> _ReduceMemory()

 


Share this post


Link to post
Share on other sites

#4 ·  Posted

I updated the script to display the Excel while running and it got through building all of the reports without crashing.

BUT

The last line of code is just a MsgBox saying finished, and after clicking on OK to that, the error popped up again.  So confusing...


Share this post


Link to post
Share on other sites

#5 ·  Posted

I'm pretty sure the error has something to do with the _Excel_Close command.

I was originally doing an _Excel_BookSaveAs, then the next line was _Excel_Close.

i switched it to the code below and no more error.  The reports that this was building have about 100+ worksheets and are about 2MB in size so I'm guessing the _Excel_BookSaveAs hadn't fully finished before the _Excel_BookClose was trying to run.

_Excel_BookSaveAs($oWorkbook, $sTargetXLSX, $xlWorkbookDefault, True)   ;Save the worksheet to the file specified

        For $w = 1 to 60                                                        ;Wait for the target file to exist
            Sleep(500)
            If FileExists($sTargetXLSX) Then ExitLoop
        Next

        _Excel_BookClose($oWorkbook, False)                                     ;Close the Workbook so we are left with just the Excel Shell Application
        _Excel_Close($oXL, False, True)                                         ;Close Excel

 


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