From: "Jody L. Meyer" Date: 2009-12-11T20:47:35+09:00 Subject: Re: Access Excel I am just learning Ruby... I found this: If a blog: http://rubyonwindows.blogspot.com/2008/01/rubygarden-archives-scripting-excel.html Opening spreadsheets, accessing workbooks and worksheets excel = WIN32OLE::new('excel.Application') workbook = excel.Workbooks.Open('c:\examples\spreadsheet.xls') Hope it helps. Jody Opening spreadsheets, accessing workbooks and worksheets excel = WIN32OLE::new('excel.Application')workbook = excel.Workbooks.Open('c:\examples\spreadsheet.xls')worksheet = workbook.Worksheets(1) #get hold of the first worksheetworksheet.Select #bring it to the front -need sometimes to run macros, # not for working with a worksheet from rubyexcel['Visible'] = true #make visible, set to false to make invisible # again. Don't need it to be visible for script to work -----Original Message----- From: jethrow@gmx.com [mailto:jethrow@gmx.com] Sent: Friday, December 11, 2009 1:46 AM To: ruby-talk ML Subject: Access Excel First off, I'm relatively new to Ruby. What I'm trying to do is access a specific Excel Workbook that is alreay open. I already know the following: - access running Excel - WIN32OLE.connect("Excel.Application") - access unsaved Excel Workbook - WIN32OLE.connect("Book1") What I'm having difficuly with is connecting to a specific Excel object (ie - if you open Excel via the Start menu, it creates a new Excel object). One way I've been able to do this in another language would be to use the full workbook name for the moniker, rather than "Book1". This doesn't seem to work with WIN32OLE.connect(moniker), however, that wouldn't be my preferred method. (if someone could let me know wha the moniker would be to connect to a running workbook that has already been saved, I would appreciate it) The method I use in another language is calling "AccessibleOjbectFromWindow" for the "EXCEL7" ChildWindow. However, I can't seem to get this to work, and I haven't been able to locate any Ruby examples for this dll call. Could someone provide an example of calling "AccessibleOjbectFromWindow" for an Excel "EXCEL7" ChildWindow? -- Posted via http://www.ruby-forum.com/.