From: Bev Jennings Date: 2010-10-28T15:55:23+09:00 Subject: Re: Excel and Ruby Hi - the info that you pointed me to has been very good and following the examples given I wrote the following code: _____________________________________________________________ require 'win32ole' data = Array.new #Opening spreadsheets, accessing workbooks and worksheets excel = WIN32OLE::new('excel.Application') workbook = excel.Workbooks.Open('d:\workgiga\ruby\programs\CVMATest.xls') worksheet = workbook.Worksheets(1) #get hold of the first worksheet worksheet.Select #bring it to the front #reading data from spreadsheet worksheet.Range('b3')['Value'] #displays value of single cell _______________________________________________________________ When I run this interactively all seems to go well until I get to the last line (trying now to get a value for a cell) I get an error message basically saying that 'Value' is unknown and undefined. When I initially wrote it using irb it worked once correctly and returned a value for each cell as requested but since then I get the error message. If I run it under SciTec I get the following error message: ____________________________________________________ ReadingExcel.rb:16:in `[]': (in OLE method `Value': ) (WIN32OLERuntimeError) OLE error code:800A03EC in HRESULT error code:0x80020009 Exception occurred. from ReadingExcel.rb:16:in `
' >Exit code: 1 _______________________________________________________ Line 16 referred to is: worksheet.Range('b3')['Value'] Any ideas of what I am doing wrong and where maybe I can get some additional documenetation on 'win32ole' where could decypher the error code.? -- Posted via http://www.ruby-forum.com/.