win32ole excel "links to other workbooks"

Z

zak

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!
 
S

Siep Korteling

zak said:
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
 
Z

zak

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?
 
Z

zak

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!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,821
Latest member
AleidaSchi

Latest Threads

Top