using System; using unoidl.com.sun.star.lang; using unoidl.com.sun.star.uno; using unoidl.com.sun.star.frame; using unoidl.com.sun.star.beans; namespace main { class Program { static void Main(string[] args) { // get the remote office component context XComponentContext xContext = uno.util.Bootstrap.bootstrap(); // get the remote office service manager XMultiComponentFactory xServiceManager = (XMultiComponentFactory)xContext.getServiceManager(); // get an instance of the office desktop UNO service // and query the XComponentLoader interface Object desktop = xServiceManager.createInstanceWithContext("com.sun.star.frame.Desktop", xContext); XComponentLoader xComponentLoader = (XComponentLoader)desktop; // create a new writer document PropertyValue[] loadProps = new PropertyValue[1]; loadProps[0] = new PropertyValue(); loadProps[0].Name = "Hidden"; loadProps[0].Value = new uno.Any(true); XComponent xComponent = xComponentLoader.loadComponentFromURL("private:factory/swriter", "_blank", 0, loadProps); // get the XStorable interface for the current document XStorable xStorable = (XStorable)xComponent; // specify the URL to save the document string saveUrl = "file:///C:/test/document_test.odt"; // create a PropertyValue to pass arguments to storeAsURL() PropertyValue[] property = new PropertyValue[1]; property[0] = new PropertyValue(); property[0].Name = "FilterName"; property[0].Value = new uno.Any("writer8"); // save the document xStorable.storeAsURL(saveUrl, property); // close the document xComponent.dispose(); } } }