[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Fetch an excel sheet name in ruby

Deepa Rajendran

2/24/2009 12:01:00 PM

hi,
I got this error.in `method_missing': Open (WIN32OLERuntimeError)
OLE error code:800A03EC in Microsoft Office Excel

For the below coding:

require 'win32ole'
require 'rubygems'

xl = WIN32OLE.new('Excel.Application')
wb = xl.Workbooks.Open("C:\Documents and
Settings\mpf18.MPFD18\Desktop\Achievement-with Target(JNJ-Wise)")
ws = wb.Worksheets(1)
puts ws.Name
wb.Close
xl.Quit
--
Posted via http://www.ruby-....

2 Answers

David Mullet

2/24/2009 1:25:00 PM

0

Deepa Rajendran wrote:
> hi,
> I got this error.in `method_missing': Open (WIN32OLERuntimeError)
> OLE error code:800A03EC in Microsoft Office Excel
>

Escape (double-up) your backslashes in double quotes, or place your
filepath in single quotes.

Change this:

wb = xl.Workbooks.Open("C:\Documents and
Settings\mpf18.MPFD18\Desktop\Achievement-with Target(JNJ-Wise)")

To this:

wb = xl.Workbooks.Open("C:\\Documents and
Settings\\mpf18.MPFD18\\Desktop\\Achievement-with Target(JNJ-Wise)")

Or this:

wb = xl.Workbooks.Open('C:\Documents and
Settings\mpf18.MPFD18\Desktop\Achievement-with Target(JNJ-Wise)')

David

http://rubyonwindows.blo...
http://rubyonwindows.blo...search/label/excel
--
Posted via http://www.ruby-....

Deepa Rajendran

2/25/2009 8:01:00 AM

0

Hi,
Thanks those who help me

Here is the coding.which i got the excel sheet name.but i
have a doubt how to use minimum and maximum value to generate random
number in ruby.

require 'win32ole'
require 'rubygems'
excel = WIN32OLE.new("excel.application")
excel.visible =false
workbook = excel.workbooks.open("E:\\Book1.xls")
tt=workbook.Worksheets.count
puts "Number of Worksheets"
puts tt.to_i
puts "Randomly Generate"
ff=rand(tt)
if ff.to_i==0
ff=1
else
ff=ff
end
puts ff.to_i
worksheet=workbook.worksheets(ff)
puts "Worksheet Name"
puts worksheet.Name
workbook.Close
excel.Quit
--
Posted via http://www.ruby-....