From: Greg Halsey Date: 2006-11-09T00:42:13+09:00 Subject: Re: win32ole and excel and copy Li Chen wrote: > Hi all, > > I use wind32ole to import data and create graphs into Excel. I find the > graphs can't be copied or resized. Any comments? > > Thanks, > > Li # 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 -- Posted via http://www.ruby-forum.com/.