Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > win32ole and excel and copy

Reply
Thread Tools

win32ole and excel and copy

 
 
Li Chen
Guest
Posts: n/a
 
      11-08-2006
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

--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
 
 
 
Greg Halsey
Guest
Posts: n/a
 
      11-08-2006
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/.

 
Reply With Quote
 
 
 
 
Li Chen
Guest
Posts: n/a
 
      11-08-2006
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/.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
WIN32OLE - failed to create WIN32OLE zxem Ruby 1 12-19-2007 07:01 PM
Help with Excel (win32ole) and threads!? Alex Ciarlillo Ruby 3 03-28-2007 04:37 PM
Help with correct syntax in win32ole and excel Li Chen Ruby 3 11-12-2006 09:13 PM
what is Deep Copy, shallow copy and bitwises copy.? saxenavaibhav17@gmail.com C++ 26 09-01-2006 09:37 PM
WIN32OLE#[] and WIN32OLE#[]= method in Ruby 1.9 (or later) Masaki Suketa Ruby 4 03-27-2006 11:17 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57