I have a script to store all Excel constants in an array. ButI can't
return the value for each constant. By using "inspect" method I think
all the constants in the array are turn into a string. The only chance I
can get the value of a constant is that I run the script to print out
all the constants and then add a line outside the array
puts Excel_Const::XlYDMFormat => return a value of 8
which is so inefficient!
I also notice that the line below will return a string
puts "Excel_Const::XlYDMFormat" => return a string as
Excel_Const::XlYDMFormat
I want to print out the values for all the constants at once. I wonder
if any expert out there can give me a hand.
See programming ruby, especially the chapter on reflection. THe
interesting methods are: Module#constants, Module#const_get
···
On 12/1/06, Li Chen <chen_li3@yahoo.com> wrote:
Hi all,
I have a script to store all Excel constants in an array. ButI can't
return the value for each constant. By using "inspect" method I think
all the constants in the array are turn into a string. The only chance I
can get the value of a constant is that I run the script to print out
all the constants and then add a line outside the array
puts Excel_Const::XlYDMFormat => return a value of 8
which is so inefficient!
I also notice that the line below will return a string
puts "Excel_Const::XlYDMFormat" => return a string as
Excel_Const::XlYDMFormat
I want to print out the values for all the constants at once. I wonder
if any expert out there can give me a hand.
WIN32OLE.const_load(excel, Excel_Const)
end
"Excel_Const::Xl3DArea"
>Exit code: 0
See programming ruby, especially the chapter on reflection. THe
interesting methods are: Module#constants, Module#const_get
Thanks Jan. I haven't touch this chapter yet but I will take a look at
them. BTW could you browse my last post about "VBA to Ruby code again"?
I change every constants into the required format and Ruby still
complains the script.