Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > win32ole excel "links to other workbooks"

Reply
Thread Tools

win32ole excel "links to other workbooks"

 
 
zak
Guest
Posts: n/a
 
      03-02-2010
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!
 
Reply With Quote
 
 
 
 
Siep Korteling
Guest
Posts: n/a
 
      03-02-2010
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=Exc elConst::XlUpdateLinksNever)
# use XlUpdateLinksAlways for the opposite effect.

# Do stuff

xl.workbooks.close
xl.quit


hth,

Siep
--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
 
 
 
zak
Guest
Posts: n/a
 
      03-03-2010
Thank you very much! Unfortunately I'm not able to implement it.
I use this concept:

http://blade.nagaokaut.ac.jp/cgi-bin...by-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=ExcelCo nst::XlUpdateLinksNever)
yield book
self.excel.ActiveWorkbook.Close(0)
end
end

Any ideas?
 
Reply With Quote
 
zak
Guest
Posts: n/a
 
      03-03-2010
I think I got it:

self.excel.Workbooks.Open(file,ExcelConst::XlUpdat eLinksNever)

instead of

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

above.

Thanks again!
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
WIN32OLE - failed to create WIN32OLE zxem Ruby 1 12-19-2007 07:01 PM
ruby/win32ole Excel Move problem Craig Moran Ruby 5 09-22-2006 04:21 PM
WIN32OLE#[] and WIN32OLE#[]= method in Ruby 1.9 (or later) Masaki Suketa Ruby 4 03-27-2006 11:17 AM
Excel file modification without win32ole Julius de Bruijn Ruby 3 02-22-2006 06:52 AM
Scrounging for WIN32OLE <--> MS-Excel Examples dhtapp Ruby 2 11-12-2003 06:20 AM



Advertisments