# Identify open workbook in excel?

**URL:** <https://www.ruby-forum.com/t/identify-open-workbook-in-excel/119925>\
**Category:** Ruby\
**Created:** [November 12, 2007, 10:59am UTC](https://www.ruby-forum.com/t/identify-open-workbook-in-excel/119925 "2007-11-12T10:59:39Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mihai](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/35a633/32.png) [@mihai](https://www.ruby-forum.com/u/mihai)\
**Post date:** [November 12, 2007, 10:59am UTC](https://www.ruby-forum.com/t/identify-open-workbook-in-excel/119925/1 "2007-11-12T10:59:39Z")

</div>

-i have an excel file ex.xls open;  
-can i make a script that will search all opened excel files and if an  
excel file is ex.xls then ex.xls it will be memorized in an ruby  
variable? how can i do that?

tbx

---

<div class="post-metadata">

**Author:** ![mihai](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/35a633/32.png) [@mihai](https://www.ruby-forum.com/u/mihai)\
**Post date:** [November 12, 2007, 11:37pm UTC](https://www.ruby-forum.com/t/identify-open-workbook-in-excel/119925/2 "2007-11-12T23:37:32Z")

</div>

Bulhac M. wrote:

> -i have an excel file ex.xls open;  
> -can i make a script that will search all opened excel files and if an  
> excel file is ex.xls then ex.xls it will be memorized in an ruby  
> variable? how can i do that?
> 
> tbx

require ‘win32ole’

# Connect to a running instance of Excel:

excel = WIN32OLE.connect(‘Excel.Application’)

# Select your workbook by name from the Workbooks collection:

my\_workbook = excel.Workbooks(‘ex.xls’)

Further discussion here:

> **[Ruby on Windows](http://rubyonwindows.blogspot.com/search/label/excel)**
>
> On using the Ruby programming language on the Microsoft Windows platform

David

> **[Ruby on Windows](http://rubyonwindows.blogspot.com)**
>
> On using the Ruby programming language on the Microsoft Windows platform
