From: Jan Svitok Date: 2006-12-02T01:26:30+09:00 Subject: Re: VBA to Ruby code again On 11/30/06, Li Chen wrote: > Jan Svitok wrote: > > On 11/30/06, Li Chen wrote: > >> Hi Jan, > >> > >> > >> > >> worksheet1.Range('A2:F2').Value=['Group A',100,200,150,200, 200] > >> > >> #chart1.PlotBy=0 #plot by columns > >> chart1.Axes(ExcelConst::XlValue, ExcelConst::XlPrimary).HasTitle = > >> chart1.SeriesCollection(1).ErrorBar Direction=xlY > >> chart1.Type=xlCustom > >> #ending session > >> excel.Quit > >> excel=nil > >> GC.start > > > > > Now, see for yourself: you use ExcelConst::XlWhatever in the > > beginning, and only xlY later. So add ExcelConst:: and make the x X > > and you'll be done. > > Hi Jan, > > This is not true. I have two versions: one is the above and the other > same as you point out. Here is the result I run the second version: > > ### > ruby macro1.rb > macro1.rb:65:in `method_missing': ErrorBar (WIN32OLERuntimeError) > OLE error code:0 in > > HRESULT error code:0x8002000f > Parameter not optional. from macro1.rb:65 > >Exit code: 1 > > line 65 is > > chart1.SeriesCollection(1).ErrorBar Direction=ExcelConst::XlY This is aonther type of error. I suppose you should do: chart1.SeriesCollection(1).ErrorBar 'Direction' => ExcelConst::XlY but it's a tip from documentation. See the programming ruby for how to transform XXX=YYY from VB to Ruby. What I'm sure about is that Direction=ExcelConst::XlY is an assignment and as such it can't work. Your line is equal to the following: Direction=ExcelConst::XlY chart1.SeriesCollection(1).ErrorBar(ExcelConst::XlY)