Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
comp.lang.ruby
Why this script doesn't work?
Li Chen
12/4/2006 4:35:00 AM
Hi all,
I copy a script from WIN32OLE documentation and run it. I find that Ruby
complains it at line cells = sheets.cells("A1:A5").
Do I miss something?
Thanks,
Li
##
require 'win32ole'
excel = WIN32OLE.new('Excel.Application')
excel.Visible="True"
book = excel.workbooks.add
sheets = book.worksheets(1)
cells = sheets.cells("A1:A5")
cells.each do |row|
row.value = 10
end
##output
>ruby test3.rb
test3.rb:13:in `method_missing': cells (WIN32OLERuntimeError)
OLE error code:80020005 in <Unknown>
<No Description>
HRESULT error code:0x80020009
Exception occurred. from test3.rb:13
>Exit code: 1
--
Posted via
http://www.ruby-...
.
3 Answers
Paul Lutus
12/4/2006 7:47:00 AM
0
Li Chen wrote:
>
> Hi all,
>
> I copy a script from WIN32OLE documentation
Where is the Win32OLE documentation located, please? That way, others can
confirm your effort and duplicate your experiment (if they are running
Windows).
--
Paul Lutus
http://www.ara...
Li Chen
12/4/2006 9:34:00 AM
0
Paul Lutus wrote:
> Where is the Win32OLE documentation located, please? That way, others
> can
> confirm your effort and duplicate your experiment (if they are running
> Windows).
It is here
http://www.ruby-doc.o...
WIN32OLE#each{|i|...} or each(WIN32OLE)in Methods section
Iterates over each item of OLE collection which has IEnumVARIANT
interface.
excel = WIN32OLE.new('Excel.Application')
book = excel.workbooks.add
sheets = book.worksheets(1)
cells = sheets.cells("A1:A5")
cells.each do |cell|
cell.value = 10
end
Li
--
Posted via
http://www.ruby-...
.
Chris Hulan
12/4/2006 1:18:00 PM
0
Li Chen wrote:
....
> cells = sheets.cells("A1:A5")
Try:
cells = sheets.Range("A1:A5")
Cheers
Chris
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
Why this script doesn't work?
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password