Dear Members,
I found a strange behaviour with the RDCOMClient package, that I cannot
explain.
If I paste into the R console the content of the function enclosed below all
is fine,
however if I try to run the function with GetCellValue() excel gets into
error while
loading the add-in.

Does anyone already got this kind error or can tell me if I miss something?
Any help is appreciated.
Thanks, Paolo


#---------------- FUNCTION -----------------------
GetCellValue<-function(){

    #Settings
    filePath<-    'C:\\'
    fileName<-    'myFile.xls'
    sheetName<-    'Sheet1'
    cellName<-    'A1'
    my.addin<-    'C:\\Program Files\\myaddin.xla'

    #Start Excel
    xls <- COMCreate("Excel.Application")
    books <- xls[["Workbooks"]]
    xls[["Visible"]]<-T

    #Load Addin
    books$Open(my.addin,updatelinks=T)

    #Load Workbook
    tryCatch({
        books$Open(paste(filePath,'\\',fileName,sep=''),updatelinks=T)
        WB <- books$item(fileName)
        SH <- WB[["worksheets"]]$item(sheetName)
        out<- SH$Range(cellName)[['Value']]
        WB$Close(SaveChanges=FALSE)
    }
    ,error = function(e) {}, finally = {rm(WB,SH)})

    system('taskkill /f /im EXCEL.EXE')

    return(out)

}

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to