From: David Mullet Date: 2009-12-13T01:56:44+09:00 Subject: Re: Access Excel jeth row wrote: > Jody L. Meyer wrote: >> Opening spreadsheets, accessing workbooks and worksheets >> >> excel = WIN32OLE::new('excel.Application') >> workbook = excel.Workbooks.Open('c:\examples\spreadsheet.xls') > > Thank you for your response. I prolly should have phrased my question > better. I know how to access the workbook if I already have access to > the correct Excel object. My question is how do I access an already > running Excel object (or process) if there is more than 1 running > (access a specific one). Again, the best way I know how is by calling > "AccessibleOjbectFromWindow", and accessing the workbook object from the > "EXCEL7" ChildWindow. If someone knows a better way, I would appreciate > that knowledge. Otherwise, if someone could provide a simple example of > this dll call, I would appreciate that as well. If the workbook has already been saved and you know the path: wb = WIN32OLE.connect('C:\Path To File\MyWorkbook.xls') This returns an instance of the Excel.Workbook object. You can then grab an instance of that Workbook's Application object: xl = wb.Application Or, of course, shorten it to a singe line: xl = WIN32OLE.connect('C:\Path To File\MyWorkbook.xls').Application Hope that helps. David http://rubyonwindows.blogspot.com/ -- Posted via http://www.ruby-forum.com/.