# Win32ole copying excel sheets

**URL:** <https://www.ruby-forum.com/t/win32ole-copying-excel-sheets/96870>\
**Category:** Ruby\
**Created:** [July 3, 2006, 12:31am UTC](https://www.ruby-forum.com/t/win32ole-copying-excel-sheets/96870 "2006-07-03T00:31:13Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![railsroad](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e274bd/32.png) [@railsroad](https://www.ruby-forum.com/u/railsroad)\
**Post date:** [July 3, 2006, 12:31am UTC](https://www.ruby-forum.com/t/win32ole-copying-excel-sheets/96870/1 "2006-07-03T00:31:13Z")

</div>

Hi,

I’m am trying to write a Ruby script that copies a worksheet from one  
Excel  
workbook to another. Does anyone know where there is some documentation  
on  
the specifically for the Excel Object Model for win32ole.

Normally I can piece together how to make the function calls in Ruby by  
recording a macro and looking at the VB code that’s generated, but I can  
figure this one out. Does anyone have any suggestions?

Thanks,

Bryan

---

<div class="post-metadata">

**Author:** ![railsroad](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e274bd/32.png) [@railsroad](https://www.ruby-forum.com/u/railsroad)\
**Post date:** [July 3, 2006, 12:43am UTC](https://www.ruby-forum.com/t/win32ole-copying-excel-sheets/96870/2 "2006-07-03T00:43:29Z")

</div>

Hi,

On 7/2/06, Bryan W. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> recording a macro and looking at the VB code that’s generated, but I can  
> figure this one out. Does anyone have any suggestions?
> 
> Thanks,
> 
> Bryan

[http://wiki.rubygarden.org/Ruby/page/show/ScriptingExcel](http://wiki.rubygarden.org/Ruby/page/show/ScriptingExcel)

That should be a start in the right direction.

Michael G.

---

<div class="post-metadata">

**Author:** ![railsroad](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e274bd/32.png) [@railsroad](https://www.ruby-forum.com/u/railsroad)\
**Post date:** [July 3, 2006, 1:00am UTC](https://www.ruby-forum.com/t/win32ole-copying-excel-sheets/96870/3 "2006-07-03T01:00:24Z")

</div>

Bryan W. wrote:

> Hi,
> 
> I’m am trying to write a Ruby script that copies a worksheet from one Excel  
> workbook to another. Does anyone know where there is some documentation on  
> the specifically for the Excel Object Model for win32ole.
> 
> Normally I can piece together how to make the function calls in Ruby by  
> recording a macro and looking at the VB code that’s generated, but I can  
> figure this one out. Does anyone have any suggestions?

Have you tried MSDN? Microsoft tends to have copious docs on their  
developer site.

---

<div class="post-metadata">

**Author:** ![railsroad](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e274bd/32.png) [@railsroad](https://www.ruby-forum.com/u/railsroad)\
**Post date:** [July 3, 2006, 1:13am UTC](https://www.ruby-forum.com/t/win32ole-copying-excel-sheets/96870/4 "2006-07-03T01:13:51Z")

</div>

I’ve taken a look at MSDN, but I can’t figure out how to translate their  
code snippets for VB and C# into Ruby. In particular the VB line that  
does  
what I am trying to accomplish is:

Sheets(“Sheet 1”).Copy After:=Workbooks(“temp.xls”).Sheets(7)

---

<div class="post-metadata">

**Author:** ![railsroad](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e274bd/32.png) [@railsroad](https://www.ruby-forum.com/u/railsroad)\
**Post date:** [July 3, 2006, 1:56am UTC](https://www.ruby-forum.com/t/win32ole-copying-excel-sheets/96870/5 "2006-07-03T01:56:33Z")

</div>

Bryan W. wrote:

> I’ve taken a look at MSDN, but I can’t figure out how to translate their  
> code snippets for VB and C# into Ruby.

Look for examples in JScript/JavaScript or VBScript. They may be easier  
to translate to Ruby. Look in the MSDN scripting section.

–  
James B.

[http://www.ruby-doc.org](http://www.ruby-doc.org) - Ruby Help & Documentation  
[Ruby Code & Style](http://www.artima.com/rubycs/) - The Journal By & For Rubyists  
[http://www.rubystuff.com](http://www.rubystuff.com) - The Ruby Store for Ruby Stuff  
[http://yourelevatorpitch.com](http://yourelevatorpitch.com) - Finding Business Focus
