[R] RCOM Package

Gabor Grothendieck ggrothendieck at gmail.com
Thu Jun 29 21:17:15 CEST 2006


Go into Excel, turn on macro recording, perform whatever operations
you want and look at whatever code is generated for you.

On 6/29/06, Thomas Sudler <thsudler at bluewin.ch> wrote:
> Hi list,
>
> I just installed the rcom package and tried to read/give out some values
> from/to Excel. Altogether it works great... but nevertheless I don't know
> how the syntax works or in other words: "Which command needs which
> parameters?"
>
> Is there somwhere a manual about this package with good examples? I've read
> the Package description... but there are not really good
> descriptions/examples.
>
> I know the following parameters/commands:
>
> #Connect to the active Workbook
> excel <- comGetObject("Excel.Application")
>
> #Set the active sheet
> sheet <- comGetProperty(excel,"ActiveSheet")
>
> #Set a specific sheet
> sheet <- comGetProperty(excel,"Worksheets","WorksheetXY")
>
> #Create a new Worksheet
> comInvoke(comGetProperty(excel,"Worksheets"),"Add")
>
> #Define a range in a defined sheet
> range1 <- comGetProperty(sheet,"Range","A1","A20")
>
> #Read out this range from Excel
> val1 <- as.double(comGetProperty(range1,"Value"))
>
> #Give back the results to Excel
> comSetProperty(range1,"Value",val1)
>
> Some of my questions are:
>
> - How can I rename a worksheet?
> - How can I define the name of a new worksheet?
> - How can I delete a worksheet?
> - How can I connect to a specific Workbook, if more than one is opened?
> - ...
>
> Can someone help me?
>
> Thanks,
> Thomas
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>



More information about the R-help mailing list