I want to use win32ole to do some automation with excel. Here is a line
code
which works.
...
ChartTypeVal=4
excel.Range("a1:b3").Select();
excelchart = workbook.Charts.Add();
excelchart.Type = ChartTypeVal;
...
I check Excel documentation: ChartTypeVal=4 is to draw a graph with
line and the name for this graph type is called xlLine. But when I
replace number 4 with name "xlLine" the script doesn't work. Which
syntax is used so that Ruby knows xlLine instead of number 4?
I want to use win32ole to do some automation with excel. Here is a line
code
which works.
...
ChartTypeVal=4
excel.Range("a1:b3").Select();
excelchart = workbook.Charts.Add();
excelchart.Type = ChartTypeVal;
...
I check Excel documentation: ChartTypeVal=4 is to draw a graph with
line and the name for this graph type is called xlLine. But when I
replace number 4 with name "xlLine" the script doesn't work. Which
syntax is used so that Ruby knows xlLine instead of number 4?
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:
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: