I am trying to access the open office spreadsheet, using below script
but following error is displayed.kindly can any one help me to over
come. Thanks in advance
require 'win32ole'
require 'rubygems'

noArgs = []
file_uri = "file:///D:/ruby/example.ods"

serviceManager = WIN32OLE.new("com.sun.star.serviceManager")
coreReflection =
desktop = serviceManager.createInstance("com.sun.star.frame.Desktop")
#spreadsheet = stardesktop.loadComponentFromURL("private:factory/
scalc", "_blank", 0, noArgs)
spreadsheet = desktop.loadComponentFromURL(file_uri , "_blank", 0,
sheetsCollection = spreadsheet.Sheets
sheet1 = sheetsCollection.getByIndex(0)
cellA1Formula = sheet1.getCellByPosition(0, 0).Formula # Gets text or
number or whatever is in the cell
cellA1NumericValue = sheet1.getCellByPosition(0, 0).Value # Gets
numericalvalue of the cell
cell1A = sheet1.getCellByPosition(0, 0) # Gets cell 1A
cell1A.Formula = "Nathan Lane" # Sets the formula for cell 1A to

Output :
excel.rb:12:in `method_missing': loadComponentFromURL
    OLE error code:1001 in [automation bridge]
      com.sun.star.lang.IllegalArgumentException: URL seems to be an
unsupported one.
    HRESULT error code:0x80020009
      Exception occurred.       from excel.rb:12
>Exit code: 1

Before posting, please read http://watir.com/support. To sum it up: search 
before you ask, be nice.

You received this message because you are subscribed to the Google Groups 
"Watir General" group.
To post to this group, send email to watir-general@googlegroups.com
To unsubscribe from this group, send email to 
For more options, visit this group at 

Reply via email to