Win32ole excel "links to other workbooks"

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!

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

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

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?

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!

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs