Win32ole and excel and copy

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

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

Greg H. 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