gcue Posted June 4, 2009 Posted June 4, 2009 (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 June 4, 2009 by gcue
Bowmore Posted June 4, 2009 Posted June 4, 2009 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
gcue Posted June 4, 2009 Author Posted June 4, 2009 (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 June 4, 2009 by gcue
PsaltyDS Posted June 4, 2009 Posted June 4, 2009 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. 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
gcue Posted June 5, 2009 Author Posted June 5, 2009 (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 June 5, 2009 by gcue
gcue Posted June 5, 2009 Author Posted June 5, 2009 i just used a processclose("excel.exe") - dirty but i could not make another way work. thanks for the replies/attempts! =)
reb Posted June 5, 2009 Posted June 5, 2009 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
gcue Posted June 5, 2009 Author Posted June 5, 2009 (edited) yep it saves. (yep i deleted it before i ran it) Edited June 5, 2009 by gcue
reb Posted June 5, 2009 Posted June 5, 2009 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.REByep it saves. (yep i deleted it before i ran it) MEASURE TWICE - CUT ONCE
reb Posted June 5, 2009 Posted June 5, 2009 CHECK IF SAVED: yesis book closed: no=(When I run it the book closes and excel closes.........Strange MEASURE TWICE - CUT ONCE
reb Posted June 5, 2009 Posted June 5, 2009 (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.REBNote: 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 June 5, 2009 by reb MEASURE TWICE - CUT ONCE
gcue Posted June 5, 2009 Author Posted June 5, 2009 hmm sounds like ur having a seperate issue.. maybe with your office install.
reb Posted June 5, 2009 Posted June 5, 2009 (edited) I took this right out of the help file and had it open a new book then save as. It works for me. #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 June 5, 2009 by reb MEASURE TWICE - CUT ONCE
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now