Yes as others have pointed out, theres no watir in anythng you provided, what you have are questions regarding how to use ruby..
a few small tips in terms of (at least from what I've seen) are the ruby way of doing some of the code you have if nu=region This is asking if "setting nu equal to region" is true.. it will always be true instead you want to use: if nu==region style wise, Instead of : rowcount = worksheet.UsedRange.Rows.Count for j in 1..rowcount {some code using j} end use: worksheet.UsedRange.Rows.Count.times.do |j| {some code using j } end Instead of : num =worksheet.Cells(j, 1).value nu=num.round(0) if nu=region puts worksheet.Cells(j, 2).value end use: puts worksheet.Cells(j, 2).value if worksheet.Cells(j, 1).value.to_i == region On Feb 22, 7:52 pm, keneda 45 <widiz...@gmail.com> wrote: > Hello, > > it's my file Excel : > > 10 "Limousin" > 11 "Lorraine" > 12 "Midi-Pyrénées" > 13 "Nord-Pas de Calais" > 14 "Basse Normandie" > 15 "Haute Normandie" > 16 Pays de la loire > 17 "Picardie" > 18 "Poitou-Charentes" > 19 "Provence-Alpes-Côte d'Azur" > 20 "Rhone-Alpes" > 21 "Corse" > 22 "Outre Mer et Etranger" > > and it's my script : > > require 'watir' > require 'win32ole' > > puts "Choisir Region > > 10=Limousin > 11=Lorraine > 12=Midi-Pyrenees > 13=Nord-Pas de Calais > 14=Basse Normandie > 15=Haute Normandie > 16=Pays de la loire > 17=Picardie > 18=Poitou-Charentes > 19=Provence-Alpes-Cote d'Azur > 20=Rhone-Alpes > 21=Corse > 22=Outre Mer et Etranger > ?" > region=gets # I ask to enter a number between 10 to 22 > > excel = WIN32OLE::new('excel.Application') > excel.DisplayAlerts = false > excel.Visible = 1 > workbook = excel.Workbooks.Open('C:\Ruby191\rv.xls') > > for i in 1 .. workbook.Worksheets.Count > > worksheet = workbook.Worksheets(i) > rowcount = worksheet.UsedRange.Rows.Count > for j in 1..rowcount > > num =worksheet.Cells(j, 1).value > nu=num.round(0) > > if nu=region > > puts worksheet.Cells(j, 2).value > > end > end > end > > with that script it array all worksheet.Cells(j, 2).value, I don't > know how to array only worksheet.Cells(j, 2).value where nu=region > > Do you have an idea? > > thx -- Before posting, please read http://watir.com/support. In short: search before you ask, be nice. watir-general@googlegroups.com http://groups.google.com/group/watir-general watir-general+unsubscr...@googlegroups.com