# Win32ole excel "links to other workbooks"

**URL:** <https://www.ruby-forum.com/t/win32ole-excel-links-to-other-workbooks/184454>\
**Category:** Ruby\
**Created:** [March 2, 2010, 8:24pm UTC](https://www.ruby-forum.com/t/win32ole-excel-links-to-other-workbooks/184454 "2010-03-02T20:24:25Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![zak](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/8e7dd6/32.png) [@zak](https://www.ruby-forum.com/u/zak)\
**Post date:** [March 2, 2010, 8:24pm UTC](https://www.ruby-forum.com/t/win32ole-excel-links-to-other-workbooks/184454/1 "2010-03-02T20:24:25Z")

</div>

Hi!

I use win32ole to access excel-workbooks.  
When ruby opens a workbook with links to other workbooks an alert box  
pops up and you have to confirm whether you want to keep those links  
or not.  
This is very annoying in my application.  
is there a way to surpress the box and choose “no” by default?

Thanks!

---

<div class="post-metadata">

**Author:** ![zak](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/8e7dd6/32.png) [@zak](https://www.ruby-forum.com/u/zak)\
**Post date:** [March 2, 2010, 11:30pm UTC](https://www.ruby-forum.com/t/win32ole-excel-links-to-other-workbooks/184454/2 "2010-03-02T23:30:35Z")

</div>

zak wrote:

> Hi!
> 
> I use win32ole to access excel-workbooks.  
> When ruby opens a workbook with links to other workbooks an alert box  
> pops up and you have to confirm whether you want to keep those links  
> or not.  
> This is very annoying in my application.  
> is there a way to surpress the box and choose “no” by default?
> 
> Thanks!

require ‘win32ole’

class ExcelConst

# to be filled with all Excelconstants

# once excel is running

end

xl = WIN32OLE.new(‘Excel.Application’)  
WIN32OLE.const\_load(xl, ExcelConst)

# All Excel constans are now available.

# NB they all start with an uppercase letter.

wb =  
xl.workbooks.open(“path\file.xls”,UpdateLinks=ExcelConst::XlUpdateLinksNever)

# use XlUpdateLinksAlways for the opposite effect.

# Do stuff

xl.workbooks.close  
xl.quit

hth,

Siep

---

<div class="post-metadata">

**Author:** ![zak](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/8e7dd6/32.png) [@zak](https://www.ruby-forum.com/u/zak)\
**Post date:** [March 3, 2010, 12:46pm UTC](https://www.ruby-forum.com/t/win32ole-excel-links-to-other-workbooks/184454/3 "2010-03-03T12:46:02Z")

</div>

Thank you very much! Unfortunately I’m not able to implement it.  
I use this concept:

[http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/245780](http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/245780)

and tried:

class ExcelConst

# to be filled with all Excelconstants

# once excel is running

end

class Excel  
attr\_accessor :excel  
def initialize  
require ‘win32ole’  
@excel = WIN32OLE::new(‘Excel.Application’)  
WIN32OLE.const\_load(@excel, ExcelConst)  
@excel.DisplayAlerts = false  
yield self  
@excel.Quit  
end

def open\_book file  
book =  
self.excel.Workbooks.Open(file,UpdateLinks=ExcelConst::XlUpdateLinksNever)  
yield book  
self.excel.ActiveWorkbook.Close(0)  
end  
end

Any ideas?

---

<div class="post-metadata">

**Author:** ![zak](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/8e7dd6/32.png) [@zak](https://www.ruby-forum.com/u/zak)\
**Post date:** [March 3, 2010, 2:45pm UTC](https://www.ruby-forum.com/t/win32ole-excel-links-to-other-workbooks/184454/4 "2010-03-03T14:45:27Z")

</div>

I think I got it:

self.excel.Workbooks.Open(file,ExcelConst::XlUpdateLinksNever)

instead of

self.excel.Workbooks.Open(file,UpdateLinks=ExcelConst::XlUpdateLinksNever)

above.

Thanks again!
