Skip to Content
author's profile photo Former Member
Former Member

AutoOpen.xls and LibreOffice or OpenOffice

With the kind assistance of Christian Lohmaier and Eduardo Moreno on the Document Foundation's LibreOffice discussion mailing list, I have managed to modify AutoOpen.xls to work with both Excel and LibreOffice (and potentially OpenOffice, though I haven't tested it).

For my company, this means we can use the export-to-Excel functionality of SAP Business One without paying double for Excel by having to buy all new licenses in order to put it on our terminal server even though everyone already uses Excel on the desktop.

For anyone else who needs to support a free office suite: I'd love to attach the file as I have it, but I'm not sure copyright issues will allow that; instead, I'm going to show you how to modify the AutoOpen.xls file you already have.

1. Use Microsoft Excel to open AutoOpen.xls and then view the Visual Basic modules. (In my experience, you must use Excel for this, because LibreOffice will strip out the very macro you're working on when you save the document out as an .xls file!)

2. Find the subroutine named OpenExlFile(). In my file, it was located in Module 2.

3. Don't delete the body of that function, but wrap it with this code:


On Error GoTo Fail1

' Assume we're running Microsoft Excel

!####### Here's where the existing function body goes ########

Exit Sub


Resume Attempt2


On Error GoTo Fail2

' Perhaps we're running LibreOffice or OpenOffice

StarOpenTsvFile (excelPath)


Exit Sub

4. Add this new subroutine in the same module:

Public Sub StarOpenTsvFile(tsvPath As String)

Dim starDesktop As Object

Dim url As String

Dim doc As Object

Dim parms(1) As New

parms(0).Name = "FilterName"

parms(0).Value = "Text - txt - csv (StarCalc)" ' Name is incorrect, but required

parms(1).Name = "FilterOptions"

parms(1).Value = "9,,65535,1" ' Tab seps, no string delim, UTF-16 charset, begin at line 1

starDesktop = createUnoService("")

url = ConvertToUrl(tsvPath)

doc = starDesktop.loadComponentFromURL(url, "_blank", 0, parms)

End Sub

5. While I was in AutoOpen, I cleaned it up a little by deleting the empty code modules and spreadsheets. On the one spreadsheet left, I added a text box with a request that the user close the workbook immediately.

This battle was hard fought. I hope putting this information out there helps someone else 😊

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • Posted on Nov 11, 2014 at 11:40 AM

    Perfect, thank you,

    worked perfectly in LibreOffice



    SAP 8.82 PL14 / SAP 9.1 PL3

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.