Sign in to follow this  
Followers 0
gcue

"excel.exe" stays resident until script exists

15 posts in this topic

#1 ·  Posted (edited)

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

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

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

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

i just used a processclose("excel.exe") - dirty but i could not make another way work.

thanks for the replies/attempts! =)

Share this post


Link to post
Share on other sites

Have you checked to see if the file you saved exists? When I run your script I can not locate the file that should have been saved.

REB


MEASURE TWICE - CUT ONCE

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

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

Edited by gcue

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

CHECK IF SAVED: yes

is book closed: no

=(

Share this post


Link to post
Share on other sites

CHECK IF SAVED: yes

is book closed: no

=(

When I run it the book closes and excel closes.........Strange :D


MEASURE TWICE - CUT ONCE

Share this post


Link to post
Share on other sites

it closes but look at ur running processes.

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

hmm sounds like ur having a seperate issue.. maybe with your office install.

Share this post


Link to post
Share on other sites

#15 ·  Posted (edited)

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

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