From: James Britt Date: 2006-11-30T15:28:46+09:00 Subject: Re: VBA to Ruby code again Li Chen wrote: > Hi all, > > I want to add error bars to a chart. I record excel macro and then try > to translate them into Ruby codes but fail. I wonder if someone there > can help me out. > > Thanks, > > Li > > # VBA macro codes > > ActiveChart.SeriesCollection(1).Select > ActiveChart.SeriesCollection(1).ErrorBar Direction:=xlY, > Include:=xlBoth, _ > Type:=xlCustom, Amount:="=Sheet1!R5C2:R5C6", MinusValues:= _ > "=Sheet1!R5C2:R5C6" What are xlCustom and xlBoth? > > #my Ruby codes > # I already creat an object reference called chart1 > # also define Excel constants at the start of the script > > chart1.SeriesCollection(1).Select > chart1.SeriesCollection(1).HasErrorBars = "True" > > chart1.SeriesCollection(1).ErrorBar Direction=xlY > chart1.Include=xlBoth > chart1.Type=xlCustom > chart1.Amount="=Sheet1!R5C2:R5C6" > chart1.MinusValues="=Sheet1!R5C2:R5C6" > >> ruby macro1.rb > macro1.rb:64: undefined local variable or method `xlY' for main:Object I'm guessing that the VBA code is using built-in constants that your Ruby code knows nothing about. You may need to find out the VBA values of xlCustom and xlBoth (I'm thinking they are integers), then recreate these in your Ruby code. (If you're doing much VBA porting it can be a big help to get a list of VBA constants and their values, and create a Ruby file to define them in one place.) James Britt