[Wtr-general] Can I attach to an open Excel session?

Chris McMahon christopher.mcmahon at gmail.com
Fri Dec 8 22:48:13 EST 2006


On 12/8/06, Lou Wilson <forum-watir-users at openqa.org> wrote:
>
> I currently use Excel macros to generate Ruby/Watir scripts and execute
> them.  One of the things I'd like to do is have the Ruby/Watir script write
> to the open Excel file.


@path = File.expand_path("wholefile.xls")

    @excel = WIN32OLE::new('excel.Application')
    @excel['Visible'] = true
    @workbook = @excel.Workbooks.Open("#{@path}")
@worksheet = @workbook.Worksheets(1)
    @worksheet.Select

<blah blah blah>

begin
assert(data1==data2)
   @worksheet.Range("#{column}11").Interior['ColorIndex'] = 4 #green
        @worksheet.Range("#{column}11")['Value'] = ['PASS']
        rescue => e
        @worksheet.Range("#{column}11").Interior['ColorIndex'] = 3 #red
        @worksheet.Range("#{column}11")['Value'] = ['FAIL']
        end
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/wtr-general/attachments/20061208/66ee6068/attachment.html 


More information about the Wtr-general mailing list