win32ole excel "links to other workbooks"

Discussion in 'Ruby' started by zak, Mar 2, 2010.

  1. zak

    zak Guest

    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, Mar 2, 2010
    #1
    1. Advertising

  2. 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
    --
    Posted via http://www.ruby-forum.com/.
    Siep Korteling, Mar 2, 2010
    #2
    1. Advertising

  3. zak

    zak Guest

    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?
    zak, Mar 3, 2010
    #3
  4. zak

    zak Guest

    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!
    zak, Mar 3, 2010
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. dhtapp
    Replies:
    2
    Views:
    120
  2. Julius de Bruijn

    Excel file modification without win32ole

    Julius de Bruijn, Feb 19, 2006, in forum: Ruby
    Replies:
    3
    Views:
    161
    Dominic Sisneros
    Feb 22, 2006
  3. Masaki Suketa
    Replies:
    4
    Views:
    377
    Dave Burt
    Mar 27, 2006
  4. Craig Moran

    ruby/win32ole Excel Move problem

    Craig Moran, Sep 21, 2006, in forum: Ruby
    Replies:
    5
    Views:
    197
    Craig Moran
    Sep 22, 2006
  5. zxem
    Replies:
    1
    Views:
    228
Loading...

Share This Page