From: Li Chen Date: 2006-11-09T07:19:29+09:00 Subject: Re: win32ole and excel and copy Greg Halsey wrote: >> # Here is sample code to copy a chart in a worksheet: > > require 'win32ole' > > xl=WIN32OLE::new('Excel.Application') > xl.Visible=1 #show excel > > xl.Workbooks.Open('c:\\testme.xls') #will open a file > > xl.sheets(1).activate #activate the sheet you want > > xl.ActiveSheet.ChartObjects("Chart 1").Activate #activate the chart > > xl.ActiveChart.ChartArea.Select > xl.ActiveChart.ChartArea.Copy > xl.Windows("testme.xls").Activate > xl.Cells(50,1).Select # select row and col to paste chart > xl.ActiveSheet.Paste > > > #xl.ActiveWorkbook.Close() > #xl.Quit > > #greg Hi Greg, I try the script but I find it only open an designated file only. I still can't copy the chart. BTW there is plug-in in Excel called Visual Basic editor. Is it the same as Visual Basic environment? Thanks, Li -- Posted via http://www.ruby-forum.com/.