Hello, I just discovered that I cannot close the Excel application and task manager shows numerous copies of Excel.exe I tried both x$Quit() # shown in the rcom archive and x$Exit() and Excel refuses to die. Thank you very much. S. "You can't kill me, I will not die" Mojo Nixon I also have a problem with saving. It produces a pop-up dialog and does not take my second parameter: x<-comCreateObject("Excel.Application") wb<-comInvoke(comGetProperty(x,"Workbooks"),"Open","G: /MR/Stephen/repo. xls", "0") sh<-comGetProperty(wb,"Worksheets","Market Data") range1 <- comGetProperty(sh,"Range","C10","I11") vals <- comGetProperty(range1,"Value") comInvoke(wb,"Close","G:/MR/Stephen/repo.xls","True") # True is ignored Thank you All. Stephen
I know it won't answer your question exactly, but using comGetObject instead of comCreateObject won't create new Excel instances, so at least you won't have more than one processes running, so this might solve some of your problems. As for your second problem, I would venture to guess you need your paths with double backslashes instead of slashes. The following just worked over here: wb<-comInvoke(comGetProperty(obj,"Workbooks"),"Open", "C:\ \Documents and Settings\\Haris\\Desktop\\test1.xlsx") Haris Skiadas Department of Mathematics and Computer Science Hanover College On Dec 14, 2007, at 2:58 PM, stephen bond wrote:> Hello, > > I just discovered that I cannot close the Excel application and task > manager shows numerous copies of Excel.exe > > I tried both > > x$Quit() # shown in the rcom archive > > and > > x$Exit() > > and Excel refuses to die. > Thank you very much. > S. > > "You can't kill me, I will not die" Mojo Nixon > > > I also have a problem with saving. It produces a pop-up dialog and > does > not take my second parameter: > > x<-comCreateObject("Excel.Application") > wb<-comInvoke(comGetProperty(x,"Workbooks"),"Open","G: > /MR/Stephen/repo. > xls", "0") > sh<-comGetProperty(wb,"Worksheets","Market Data") > range1 <- comGetProperty(sh,"Range","C10","I11") > vals <- comGetProperty(range1,"Value") > comInvoke(wb,"Close","G:/MR/Stephen/repo.xls","True") # True is > ignored > > Thank you All. > Stephen
First, you will likely have to use Ctrl-Alt-Delete - Task Manager - to kill the Excel processes. you could also try wb[["Saved"]]<-TRUE # trick Excel to think that the workbook is saved x$Quit() # close Excel rm(list=ls()) # remove all objects attached to environment Gyula On Dec 14, 11:58 am, stephen bond <sten... at go.com> wrote:> Hello, > > I just discovered that I cannot close the Excel application and task > manager shows numerous copies of Excel.exe > > I tried both > > x$Quit() # shown in the rcom archive > > and > > x$Exit() > > and Excel refuses to die. > Thank you very much. > S. > > "You can't kill me, I will not die" Mojo Nixon > > I also have a problem with saving. It produces a pop-up dialog and > does > not take my second parameter: > > x<-comCreateObject("Excel.Application") > wb<-comInvoke(comGetProperty(x,"Workbooks"),"Open","G: > /MR/Stephen/repo. > xls", "0") > sh<-comGetProperty(wb,"Worksheets","Market Data") > range1 <- comGetProperty(sh,"Range","C10","I11") > vals <- comGetProperty(range1,"Value") > comInvoke(wb,"Close","G:/MR/Stephen/repo.xls","True") # True is > ignored > > Thank you All. > Stephen > > ______________________________________________ > R-h... at r-project.org mailing listhttps://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guidehttp://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.
Thank you, getobject is a roundabout, but solves the issue. BTW I discovered that system("taskkill /f /im Excel.exe") # kills the process just fine. The second problem is not due to the backslash vs slash, you can try and see that using the forward slash works fine from ESS. The q. is how to submit a second argument to "Close"? Submitting a second argument to Open works fine as shown by the "0" below, but neither "1" nor "-1" worked for Close. Very strange. ----Original Message---- From: cskiadas at gmail.com Date: 12/14/2007 18:57 To: "stephen bond"<stenka1 at go.com> Cc: <r-help at r-project.org> Subj: Re: [R] rcom close Excel problem I know it won't answer your question exactly, but using comGetObject instead of comCreateObject won't create new Excel instances, so at least you won't have more than one processes running, so this might solve some of your problems. As for your second problem, I would venture to guess you need your paths with double backslashes instead of slashes. The following just worked over here: wb<-comInvoke(comGetProperty(obj,"Workbooks"),"Open", "C:\ \Documents and Settings\\Haris\\Desktop\\test1.xlsx") Haris Skiadas Department of Mathematics and Computer Science Hanover College On Dec 14, 2007, at 2:58 PM, stephen bond wrote:> Hello, > > I just discovered that I cannot close the Excel application and task > manager shows numerous copies of Excel.exe > > I tried both > > x$Quit() # shown in the rcom archive > > and > > x$Exit() > > and Excel refuses to die. > Thank you very much. > S. > > "You can't kill me, I will not die" Mojo Nixon > > > I also have a problem with saving. It produces a pop-up dialog and > does > not take my second parameter: > > x<-comCreateObject("Excel.Application") > wb<-comInvoke(comGetProperty(x,"Workbooks"),"Open","G: > /MR/Stephen/repo. > xls", "0") > sh<-comGetProperty(wb,"Worksheets","Market Data") > range1 <- comGetProperty(sh,"Range","C10","I11") > vals <- comGetProperty(range1,"Value") > comInvoke(wb,"Close","G:/MR/Stephen/repo.xls","True") # True is > ignored > > Thank you All. > Stephen
Several weeks ago my father told me one funny or not thing. I suggested him a tool for resolving a trouble. To my great surprise it helped him and father thanked me a lot and presented a gift. I suppose that this tool might be good solution for solving varied troubles with excel files - http://www.recoverytoolbox.com/how_can_i_view_xlsx_files_from_microsoft_excel.html excel xlsx viewer . -- View this message in context: http://r.789695.n4.nabble.com/rcom-close-Excel-problem-tp843030p3036389.html Sent from the R help mailing list archive at Nabble.com.