Christian Madsen wrote: > Excel.XlChartType.xlLine won't work the same way in Ruby as in Visual > Basic. > > The reason is that in the VB example, the constant xlLine in > XlChartType is accessed. In Ruby, constants must start with a capital > e.g. XlLine. This is however not implemented in Win32ole, so you must > load all the constants of the Excel typelibrary into a class or module > of your own: > > class ExcelConst > end > > WIN32OLE.const_load(excel, ExcelConst) > > excelchart.ChartType = ExcelConst.XlLine > > Note that xlLine now becomes XlLine. > > The first four lines of the example are taken from > http://wiki.rubygarden.org/Ruby/page/show/ScriptingExcel which is the > best guide to automating Excel via Ruby that exists. > > Rgds, > Christian Many thanks to you all. Here is the wroking script on my XP: ########### require 'win32ole' class ExcelConst end excel = WIN32OLE.new("Excel.Application") workbook = excel.Workbooks.Add excel.Range("a1:b1").Value= [3,10] excel.Range("a2:b2").Value= [2,6] excel.Range("a3:b3").Value = [1,3] excel.Range("a1:b3").Select excelchart = workbook.Charts.Add WIN32OLE.const_load(excel, ExcelConst) excelchart.ChartType = ExcelConst::XlConeCol savefile='C:\Ruby\self\excel3.xls' workbook.SaveAs(savefile) excel.ActiveWorkbook.Close(0) excel.Quit() ######### In Ruby constant is accessed as ExcelConst::XlLine but not as ExcelConst.XlLine. Li -- Posted via http://www.ruby-forum.com/.