Then you have to establish a reference anyway. The alternatove to the Auto_Open macro is to use Tools->References in the VBA IDE.
Lindsay, Dwayne wrote: > Sorry, let me provide further information: > > I strictly start R via VBA programming. As such, I have experienced a > failure in either R or Excel, (not sure which side this is on), to load > the appropriate references. It's no big deal, but has caused to time to > troubleshoot the issue. > > I hope this clarifies my previous note. > D- > > -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of Erich > Neuwirth > Sent: Wednesday, November 14, 2007 12:30 PM > To: R (D)COM and RExcel server related issues > Subject: Re: [Rcom-l] Resources for calling Excel from R > > Does that mean that starting R from the RExcel menu > and then using Get R Value or Get R dataframe does not work? > > The reference you introduce should not be necessary if you do as > described above. If you do it this way and it does not work, please give > more information. > > > Lindsay, Dwayne wrote: >> Dear all- >> >> With recent upgrades/version of R, I have found that most of my > programs >> now fail to execute because the proper libraries/references fail to >> load. As such, I have had to use the following VBA code in the: >> Auto_Open(), macro to load the appropriate libraries/references: >> >> 'Auto add Rexcel.xla references >> strAdd = "C:\Program Files\R\(D)COM Server\xls\RExcel.xla" >> >> On Error GoTo 111 >> SendKeys "{ENTER}" >> ThisWorkbook.VBProject.References.AddFromFile strAdd >> >> 111 Err.Number = 0 >> >> Especially, with R 2.6.0, I now have 5-8 libraries to load just to get >> my Excel based programs to work. I try to avoid VBA programming like >> the plaque, so I tend to get everything in to R then, use R as a > client >> to obtain my results. In this manner, I find myself doing a lot less >> maintenance on my programs. >> >> Hope this helps someone out there. >> Dwayne >> >> -----Original Message----- >> From: [EMAIL PROTECTED] >> [mailto:[EMAIL PROTECTED] On Behalf Of > Charilaos >> Skiadas >> Sent: Wednesday, November 14, 2007 10:50 AM >> To: R ((D))COM and RExcel server related issues >> Subject: Re: [Rcom-l] Resources for calling Excel from R >> >> On Nov 14, 2007, at 9:50 AM, Prokaj Vilmos wrote: >> >>> I resend this message. This was sent previously in reply to another >>> message. >>> >>> Hi, >>> >>> I use rcom in a similar way as you plan to do. I usually start with >>> Visual >>> Basic of Excel. Then I simply translate the VBA code to R code (macro >>> recorder could help a lot, and for the contants there is the built in >>> object browser). If you want to get all data from a spreadsheet the >>> usedrange property could help you. Example >>> >>> XL<-comGetObject("Excel.application") >>> r<-XL[["activesheet"]][["usedrange"]][["value"]] >>> >>> gives a matrix of the values from the activesheet. >>> Sometimes value2 property is also useful >>> I hope this helps >> Thanks Prokaj, this was indeed the connecting link I was looking for. > >> I had not realized that VBA and COM were essentially different sides >> of the same coin. So this means I now have to learn a bit of VBA, >> which I have always avoided (never had to use Word/Excel, and not a >> Windows user for more than 2 years), and I need to locate the library > >> reference for VBA functions (which so far has seemed far from >> trivial; any links for a "VBA newbie but long time programmer" would >> be welcome). >> >> One further question, is the "bracketing" approach recommended, over >> the comGetProperty approach? I.e. any advantages over one or the >> other of: >> >> comGetProperty(comGetProperty(ws,"UsedRange"),"Value") >> ws[["UsedRange"]][["Value"]] >> >> I suppose I don't quite see what the syntax would have been for >> getting the equivalent of: >> >> comGetProperty(ws,"Range","A1","B4") >> >> but it seems that this works: >> >> ws[["Range","A1","B4"]] >> >> Ok, I just read the documentation for [[.COMObject, and it now makes >> a bit more sense. Isn't that a somewhat unusual use of [[ though? >> Merely worrying for aesthetic reasons. >> >>> Vilmos Prokaj >>> >> Haris Skiadas >> Department of Mathematics and Computer Science >> Hanover College >> >> >> >> >> _______________________________________________ >> Rcom-l mailing list >> [email protected] >> http://mailman.csd.univie.ac.at/mailman/listinfo/rcom-l >> More information (including a Wiki) at http://rcom.univie.ac.at >> _______________________________________________ >> Rcom-l mailing list >> [email protected] >> http://mailman.csd.univie.ac.at/mailman/listinfo/rcom-l >> More information (including a Wiki) at http://rcom.univie.ac.at >> >> > > _______________________________________________ > Rcom-l mailing list > [email protected] > http://mailman.csd.univie.ac.at/mailman/listinfo/rcom-l > More information (including a Wiki) at http://rcom.univie.ac.at > _______________________________________________ > Rcom-l mailing list > [email protected] > http://mailman.csd.univie.ac.at/mailman/listinfo/rcom-l > More information (including a Wiki) at http://rcom.univie.ac.at > > _______________________________________________ Rcom-l mailing list [email protected] http://mailman.csd.univie.ac.at/mailman/listinfo/rcom-l More information (including a Wiki) at http://rcom.univie.ac.at
