Excel Range Replace

D

dkmd_nielsen

I'm not able to figure out the implementation of Excel's Range Replace
function through Ruby/win32ole. I thought the snippent at the end
would be correct correct, but I keep getting Ole errors. Obviously,
I'm doing a poor job at interpretting the available information out
there (Dave Thomas, wiki.RubyGarden, etc.) I'm just not getting it.

While I would appreciate the solution to my problem, I would really
appreciate an explanation of when and how to use pointers-to-objects
when working with win32ole.

Much appreciated.
dvn


require 'win32ole'
class ExcelConst
end
wb = WIN32OLE.connect("excel.application")
WIN32OLE.const_load(wb, ExcelConst)
ws = wb.ActiveSheet
ws.Range("C:D").Replace('What'=>'nail',
'Replacement'=>'hammer',
'LookAt'=>ExcelConst::xlPart,
'SearchOrder'=>ExcelConst::xlByRows,
'MatchCase'=>ExcelConst::False,
'SearchFormat'=>ExcelConst::False,
'ReplaceFormat'=>ExcelConst::False
)
 
G

greg.rb

try this:

require 'win32ole'
wb = WIN32OLE.connect("excel.application")
wb.Visible=1 #show the sheet
ws = wb.ActiveSheet
ws.Range("C:D").Replace('nail','hammer')
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top