Win32ole Copy/Paste


(Fowler, Chad (GEA, BLR, L088862)) #1

Nevermind. I solved my own problem. Needed to call “Select” on the the
excel application object. I’m not sure why, but I don’t mind accepting it
on faith at this point. :slight_smile:

Sorry for the line noise.

Chad

···

-----Original Message-----
From: Fowler, Chad (GEA, BLR, L088862) [mailto:Chad.Fowler@geind.ge.com]
Sent: Wednesday, June 05, 2002 1:51 PM
To: ruby-talk@ruby-lang.org
Subject: win32ole Copy/Paste

Has anyone had any issues with using copy/paste with win32ole and Excel?
I’m fairly ignorant when it comes to Windows automation. Trying to automate
some Excel stuff at the office and running into the following:

If I have code that looks like this (assuming “sheet” is a reference to a
worksheet):
sheet.Range(“A:J”).Select

I see this:
C:\My Documents>ruby consolidate_data.rb
consolidate_data.rb:23:in method_missing': Select (WIN32OLERuntimeError) OLE error code:1004 in Microsoft Excel Unable to get the Select property of the Range class HRESULT error code:0x80020009 Exception occurred from consolidate_data.rb:23:indo_rts’
from consolidate_data.rb:49
from consolidate_data.rb:47:in `each’
from consolidate_data.rb:4

I’m using the Pragmatic Programmers’ Ruby 166 (win32 build) with Excel 97 on
(gack) Win98. Any pointers would be appreciated.

Thanks,
Chad

“THIS E-MAIL MESSAGE ALONG WITH ANY ATTACHMENTS IS INTENDED ONLY FOR THE
ADDRESSEE and may contain confidential and privileged information.
If the reader of this message is not the intended recipient,
you are notified that any dissemination, distribution or copy of this
communication is strictly Prohibited.
If you have received this message by error, please notify us
immediately, return the original mail to the sender and delete the
message from your system.”

“THIS E-MAIL MESSAGE ALONG WITH ANY ATTACHMENTS IS INTENDED ONLY FOR THE
ADDRESSEE and may contain confidential and privileged information.
If the reader of this message is not the intended recipient,
you are notified that any dissemination, distribution or copy of this
communication is strictly Prohibited.
If you have received this message by error, please notify us
immediately, return the original mail to the sender and delete the
message from your system.”