Mass convert MS Office files to LibreOffice ODF

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
someware
Posts: 19
Joined: Wed Feb 05, 2014 6:29 pm

Mass convert MS Office files to LibreOffice ODF

Post by someware »

Hello everyone,

for a company wide integration of LibreOffice I need to convert all existing MS Office files (a few thousand) to LiberOffice.
First Problem and a big dealbreaker is the fact that already some slightly wrong formatted files(A few empty lines are formatted as Headers) wont be opened and stall the whole process.
They also wont open manually, only after I opened them in MS Word(Currently im converting only Word files) and removed the formatting of the empty lines will they open in LibreOffice.

Isnt there a way to open the documents without validating and search through Headers, correct them and then open it completely ?
Or will I have to code the correcting process for MS Office with interop ?

I open with the following code, the code is sound and worked before without problems.
Code is C#

Code: Select all

private static XComponent Open(string path, XMultiServiceFactory factory, PropertyValue[] param)
        {
            var sheetprops = new List<PropertyValue>();
            var loader = (XComponentLoader)factory.createInstance("com.sun.star.frame.Desktop");
            var url = string.Empty;
            if (!path.Contains("private:factory"))
            {
                if (!File.Exists(path))
                    throw new FileNotFoundException(path);

                url = CorrectUnoPath(path);
            }
            else
                url = path;

            sheetprops.Add(FormatOperations.GetHiddenProp());
            if(param != null)
                foreach(var value in param)
                    sheetprops.Add(value);

            var doc = loader.loadComponentFromURL(url, "_blank", 0, sheetprops.ToArray());

            if (doc == null)
                throw new ArgumentNullException("Ursache: Document is null");

            return doc;
        }
Best Regards and thanks for any help in advance.
LibreOffice, Version: 4.3.3.2, Win 8.1 proffessional 64 bit
someware
Posts: 19
Joined: Wed Feb 05, 2014 6:29 pm

Re: Mass convert MS Office files to LibreOffice ODF

Post by someware »

If there is anything unclear please dont hesitate to ask.
When I speak of wrong formated Header I mean Headlines, just to be clear.

Best Regards.
LibreOffice, Version: 4.3.3.2, Win 8.1 proffessional 64 bit
User avatar
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Mass convert MS Office files to LibreOffice ODF

Post by Villeroy »

Enable some 32-bit Java in Tools>Options>Java settings and call menu:File>Wizzard>Document Converter...
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Post Reply