Thanks, it did not work but this worked: xl$Workbooks()$Open("\\sample_file.xls")$Sheets()$Count()
Cheers, Lauri 2009/7/2 Henrique Dallazuanna <www...@gmail.com>: > Try this: > > xl$Workbooks()$Open("/sample_file.xls")$Sheets()$Count() > > On Thu, Jul 2, 2009 at 2:23 PM, Lauri Nikkinen <lauri.nikki...@iki.fi> > wrote: >> >> Thanks, I tried and got this error: >> >> > setwd("C:/") >> > list.files(pattern=".xls") >> [1] "sample_file.xls" >> > library(RDCOMClient) >> > xl <- COMCreate("Excel.Application") >> > xl$Workbooks()$Open("sample_file.xls")$Sheets()$Count() >> Error in .COM(x, name, ...) : >> 'sample_file.xls' could not be found. Check the spelling of the file >> name, and verify that the file location is correct. >> >> If you are trying to open the file from your list of most recently >> used files on the File menu, make sure that the file has not been >> renamed, moved, or deleted. (Microsoft Excel) >> > >> >> Any ideas how to proceed? >> -L >> >> 2009/7/2 Henrique Dallazuanna <www...@gmail.com>: >> > Try this: >> > >> > >> > library(RDCOMClient) >> > >> > xl <- COMCreate("Excel.Application") >> > xl$Workbooks()$Open("teste.xls")$Sheets()$Count() >> > >> > >> > On Thu, Jul 2, 2009 at 11:22 AM, Lauri Nikkinen <lauri.nikki...@iki.fi> >> > wrote: >> >> >> >> Hi, >> >> >> >> I'm trying to read several Excel sheets from an Excel file into a >> >> list. I'm using >> >> read.xls from package 'gdata'. I would like to know how I can >> >> check the number of sheets before the loop (in the example below) so >> >> that I could adjust the loop counter? Any suggestions? >> >> >> >> DF.list <- list() >> >> for (i in 1:4) { >> >> DF.list[[i]] <- read.xls("sample_file.xls", sheet=i, >> >> stringsAsFactors = FALSE) >> >> } >> >> >> >> Thanks, >> >> -L >> >> >> >> ______________________________________________ >> >> 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. >> > >> > >> > >> > -- >> > Henrique Dallazuanna >> > Curitiba-Paraná-Brasil >> > 25° 25' 40" S 49° 16' 22" O >> > > > > > -- > Henrique Dallazuanna > Curitiba-Paraná-Brasil > 25° 25' 40" S 49° 16' 22" O > ______________________________________________ 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.