From: Christian Madsen Date: 2006-11-13T05:35:05+09:00 Subject: Re: Help with correct syntax in win32ole and excel Li Chen skrev: > if I change this line > excelchart.ChartType = ChartTypeVal; > > into excelchart.ChartType= excelchart.XlChartType.xlLine > > I get the following message: > > excel1.rb:37:in `method_missing': unknown property or method > `XlChartType' (WIN32OLERuntimeError) > HRESULT error code:0x80020006 > Unknown name. from excel1.rb:37 > Hi Li and Jan, 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