title: openoffice ole automation
body: <p>I'm trying to automate openoffice calc through ole automation from a c# application. I'm opening a document and saving it again. Code is mostly downloaded from Apache web site with few modifications. </p>
  
  <pre><code>    private void OpenSave(string FileAddress)//format: "file:///C:/Untitled1.ods"
      {
          Type t_OOo= Type.GetTypeFromProgID("com.sun.star.ServiceManager");
          Object objServiceManager= System.Activator.CreateInstance(t_OOo);
  
          // arguments for IDispatch-call 
          Object[] parameters = new Object[1];
          parameters[0] = "com.sun.star.frame.Desktop";
  
          // arguments for document 
          Object[] args = new Object[4];
          //args[0] = "private:factory/scalc";
          args[0] = FileAddress;         
          args[1] = "_blank";
          args[2] = 0;
          args[3] = new Object[] { };
  
          Object desktop;
          Object doc;
          try
          {
              desktop = (Object)t_OOo.InvokeMember("createInstance",BindingFlags.InvokeMethod, null,objServiceManager, parameters);
              doc = desktop.GetType().InvokeMember("loadComponentFromUrl",BindingFlags.InvokeMethod, null, desktop, args);
  
              if (doc == null)
              {/*Error*/ }
  
              object[] O = new object[3];
              O[0] = FileAddress;
              O[1] = new PropertyValue();
              ((PropertyValue)O[1]).Name = "";
              ((PropertyValue)O[1]).Value = true;
              O[2] = new Object[] { };
  
              desktop.GetType().InvokeMember("storeAsURL", BindingFlags.InvokeMethod, null, desktop,O);            
          }
          catch (Exception e1)
          {
              Console.WriteLine(e1);
          } 
  </code></pre>
  
  <p>Last line of code (saveTOURL) always throws exception of "Unknown name"(exact exception: [System.Runtime.InteropServices.COMException] = {"Unknown name. (Exception from HRESULT: 0x80020006 (DISP_E_UNKNOWNNAME))"}). May Anybody help? Please consider that I'm mostly opening xls files with this program.</p>
  
  <p>In fact documentation about c# &amp; OLE is not rich enough. All documentation is in Java and I had to compare Java to few ole samples available to find a weak clue about object model.</p>
  
  <p>I want to be able to modify a cell's value before saving, I would be grateful if you could guide me about this one also.</p>