Jump to content

"excel.exe" stays resident until script exists


Recommended Posts

hello.

i am noticing that there is an extra "excel.exe" process that remains resident until the script exists..

1. i create the workbook (visible/invisiible mode)

2. i save it

3. i close it

4. i open the workbook

there are two running instances of excel, when i close the file the other remains until i exit the script..

what can i do to prevent this?

thanks

#include <excel.au3>

$results = "c:\eh.xls"

$oExcel = _ExcelBookNew(0)

_ExcelSheetAddNew($oExcel, "PRINTERS")
    
_ExcelBookSaveAs($oExcel, $results, "xls", 0, 1)
_ExcelBookClose($oExcel, 1)
_ExcelBookOpen($results, 1)
msgbox(0,"","")
Edited by gcue
Link to comment
Share on other sites

you need to close excel. Currently you are only closing the workbook

$oExcel.Quit

"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook

Link to comment
Share on other sites

hmm i added it right after the close and the problem persists..

i also tried $oExcel.Application.Quit

also there are no excel processes running before i run the script.

#include <excel.au3>

$results = "c:\eh.xls"

$oExcel = _ExcelBookNew(0)

_ExcelSheetAddNew($oExcel, "PRINTERS")
   
_ExcelBookSaveAs($oExcel, $results, "xls", 0, 1)
_ExcelBookClose($oExcel, 1)
;$oExcel.Application.Quit
$oExcel.Quit
_ExcelBookOpen($results, 1)
msgbox(0,"","")
Edited by gcue
Link to comment
Share on other sites

hmm i added it right after the close and the problem persists..

i also tried $oExcel.Application.Quit

also there are no excel processes running before i run the script.

#include <excel.au3>

$results = "c:\eh.xls"

$oExcel = _ExcelBookNew(0)

_ExcelSheetAddNew($oExcel, "PRINTERS")
   
_ExcelBookSaveAs($oExcel, $results, "xls", 0, 1)
_ExcelBookClose($oExcel, 1)
;$oExcel.Application.Quit
$oExcel.Quit
_ExcelBookOpen($results, 1)
msgbox(0,"","")
Well, you did _ExcelBookOpen() immediately AFTER doing $oExcel.Quit.

:D

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

even if i comment that excelbookopen line there's still a resident "excel.exe" process that lingers until i close the message box (which exits the script)

the excelbookopen line accounts for the second of the "excel.exe" process i mentioned in my first post.

Edited by gcue
Link to comment
Share on other sites

Maybe I am having trouble with my Excel.au3 because I get a error when it trys to save.

Did you try to step through and see if excel was closing properly? I opened the book in visible mode to see what was going on.

ran your code like this :

#include <excel.au3>

MsgBox(0,"","start 1")

$results = "c:\eh.xls"

$oExcel = _ExcelBookNew(1)

MsgBox(0,"","start 2")

_ExcelSheetAddNew($oExcel, "PRINTERS")

_ExcelBookSaveAs($oExcel, $results, "xls", 0, 1)

MsgBox(0,"","CHECKED IF SAVED")

_ExcelBookClose($oExcel, 1)

MsgBox(0,"","start 3" & " Is book closed?")

_ExcelBookOpen($results, 1)

MsgBox(0,"","start 4" & $results)

All I can do until I find out why it does not save for me.

REB

yep it saves. (yep i deleted it before i ran it)

MEASURE TWICE - CUT ONCE

Link to comment
Share on other sites

it closes but look at ur running processes.

When I run the script and am viewing processes I see excel start and I see excel drop out when script ends.

REB

Note: I have the save commented out when I am doing this as the save hangs up the script and I have to manually close excel if save is called.

Edited by reb

MEASURE TWICE - CUT ONCE

Link to comment
Share on other sites

I took this right out of the help file and had it open a new book then save as. It works for me. :D

#include <Excel.au3>

$sFilePath1 = @ScriptDir & "\Test1.xls" ;This file should already exist

;~ $oExcel = _ExcelBookOpen($sFilePath1)

$oExcel = _ExcelBookNew(1)

If @error = 1 Then

MsgBox(0, "Error!", "Unable to Create the Excel Object")

Exit

ElseIf @error = 2 Then

MsgBox(0, "Error!", "File does not exist - Shame on you!")

Exit

EndIf

_ExcelSheetAddNew($oExcel, "PRINTERS") ; added this works too

_ExcelBookSaveAs($oExcel, @ScriptDir & "\SaveAsExample3", "xls")

If Not @error Then MsgBox(0, "Success", "File was Saved!", 3)

_ExcelBookClose($oExcel, 1, 0) ;This method will save then Close the file, without any of the normal prompts, regardless of changes

Edited by reb

MEASURE TWICE - CUT ONCE

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