Forum Discussion

murugans1011's avatar
murugans1011
Regular Contributor
11 years ago

problem in working with excel via com server

hi does excel needed to be installed to work with com server?



  Sys.oleobject("Excel.Application") gives error "invalid class ID" when the excel is not



installed.we hav scenario where tests run in multiple environments. does excel need to be installed in all virtual machines?
  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor
    Yes.  The COM objects for Excel are not present if Excel is not installed.
  • murugans1011's avatar
    murugans1011
    Regular Contributor
    Hi Thanks for your reply. can we use "Open office  Calc" instead of  Ms excel to work with excel files. if so how it can be used?
  • murugans1011's avatar
    murugans1011
    Regular Contributor
    HI Alexei Karas ,



     
    Thanks for your reply. tat link was really helpful. ill  try  and post result here soon whether can able to access excel files with Open office.



    Thank you.

  • murugans1011's avatar
    murugans1011
    Regular Contributor
    Hi i can able to write data to xls through open office



    Example







    Sub Main()





      Set ServiceManager = CreateObject("com.sun.star.ServiceManager")



    Dim propertyN

    Set propertyN = ServiceManager.Bridge_GetStruct("com.sun.star.beans.PropertyValue")



      propertyN.Name = "Hidden"

      propertyN.Value = True



      Set Desktop = ServiceManager.createInstance("com.sun.star.frame.Desktop")



      arr = Array()



      Set Document = Desktop.LoadComponentFromURL("file:///C:\temp.xls", "_blank", 0, arr)



      Set Sheets = Document.getSheets()



      Set Sheet = Sheets.getByName(SheetName)



      Sheet.getCellByPosition(8, 1).String="PASS"



       Document.Store

         Document.Close (True)

    Desktop.terminate

    End Sub





    the problem is that   Set ServiceManager = CreateObject("com.sun.star.ServiceManager")

     is actually opening doucment in GUI. i dont want document to be visible in gui when editing.. So i have used hidden property in code. but there is no effect on operation and the document is still visible in screen when editing.