From: David Mullet Date: 2008-07-08T07:26:33+09:00 Subject: Re: How to point to proper worksheet in excel Marcin Tyman wrote: > I have following code: > > @xl = WIN32OLE.new('Excel.Application') > @xl['Visible'] = TRUE > @wb = @xl.Workbooks.Add > @ws = @xb.Worksheets("XXXXX") > > The problem is that last line throws exception: moethod_missing: > Worksheets > > Why? I had read examples from net and did everything according to them. > As Paul mentioned, you had a typo, where "@xb" should be "@wb". A newly-created workbook (which you created via the Workbooks.Add method) will have the default worksheet names (ie, Sheet1", "Sheet2")... @ws = @wb.Worksheets("Sheet1") You'll find details about working with Excel's workbook and worksheet objects, with Ruby, here: http://rubyonwindows.blogspot.com/2007/03/automating-excel-with-ruby-workbook.html http://rubyonwindows.blogspot.com/2007/04/automating-excel-with-ruby-worksheet.html http://rubyonwindows.blogspot.com/search/label/excel > Another question is how to create a chart in excel and: > add several series to it > named it > assign names to axis > assign names to the series > set chart type. See my reply to your other post here specifically about Excel charts. David http://rubyonwindows.blogspot.com -- Posted via http://www.ruby-forum.com/.