Jump to content

AutoCAD use LibreOffice instead of Excel


Recommended Posts

Getting somewhere, thanks to Virgil at Bricscad forum.


There seems not to be much information on this topic.

I could find a few articles (not all in english) with some references about how to connect from Calc to Autocad, using StarBasic.

Regarding the reverse connection, I could only find this old forum post, but there is nothing specific.


Lots of good code to look at can run VBA code from Lisp, but will probably look at convert the VBA to lisp. I guess may have to bite the bullet and down load Libreoffice calc if to go any further. Bit busy at moment, may just do some try to open code. 


definitely look at Creating DWG files with LibreOffice and progeCAD - Roberto Rossi (redchar.net) try the sample file, let me know how it goes.

Edited by BIGAL
Link to comment
Share on other sites

I really don't see doing this at the LISP level. Really need to just use LISPs for generic text files and bypass Calc, IMHO.


I looked at all of this a while ago, seems no major changes since then.


LibreOffice also is not compatible with Microsoft VBA, it has it's own language, a version of BASIC. LibreOffice BASIC Programming Guide - The Document Foundation Wiki



VBA : Compatibility between LibreOffice Basic and VBA relates to the LibreOffice Basic language as well as the runtime library. The LibreOffice API and the Dialog Editor are not compatible with VBA (standardizing these interfaces would have made many of the concepts provided in LibreOffice impossible).


Import MS-Word Macros - English - Ask LibreOffice




Link to comment
Share on other sites

Well this works for put cells try this using VBA in Acad or Bricscad. Opens a blank document and puts some values so a big success. 




Sub Main()
        Dim obL_Service_Manager As Object
        Dim obL_Core_Reflection As Object
        Dim obL_Desktop As Object
        Dim srL_Url As String
        Dim obL_Calc_Document As Object
        Dim obL_Sheet As Object
        Dim obL_Range_First_Column As Object
        Dim obL_Range_ToSort As Object
        Dim a1L_Arguments()
        Dim lnL_iLast_Row As Long
        Dim lnL_iLast_Column As Long
        Set obL_Service_Manager = CreateObject("com.sun.star.ServiceManager")
        Set obL_Core_Reflection = obL_Service_Manager.createInstance("com.sun.star.reflection.CoreReflection")
        Set obL_Desktop = obL_Service_Manager.createInstance("com.sun.star.frame.Desktop")
        srL_Url = "private:factory/scalc"
        Set obL_Calc_Document = obL_Desktop.loadComponentFromURL(srL_Url, "_blank", 0, a1L_Arguments)
        Set obL_Sheet = obL_Calc_Document.Sheets.getByIndex(0)

        obL_Sheet.getCellRangeByName("A1").String = "PAPERINO"
      obL_Sheet.getCellRangeByName("C6").Value = 200
      obL_Sheet.getCellRangeByName("C7").Value = 100
      End Sub

I did down load Libre office only way to work out anything. Next step is open a known Ods file. See srl = 

Edited by BIGAL
Link to comment
Share on other sites

No LibreOffice at work, maybe tonight I will have time at home.


I am still reading through all of the information I have linked here.


One of those sites has a link to a Sun Microsystems StarOffice programming guide which OpenOffice and LibreOffice is from the source code that was released, that's why all of (com.sun.star.) references. From what I have found on StarOffice, they had a Macro Converter for converting Microsoft Office VBA macros to StarOffice Basic. I am not sure if it was ever open sourced.


There is an online converter, not sure how well it works... Excel VBA to OpenOffice Basic Converter


Here is a PDF on converting VBA to StarBasic from OpenOffice VbaStarBasicXref.pdf


I also found that adding 


option vbasupport 1


to the top of  VBA code will work in some cases (newer releases).

Link to comment
Share on other sites

I would still like to see a before and after example of what exactly is being modified.


There still may be a better method to get this done.

Link to comment
Share on other sites

Here I sent a sample of what it looks like before and after 

On 2/9/2024 at 9:34 AM, Truski said:


Hi SLW210, I am familiar with the Batch Attribute Editor application from LEE MAC. It works very well but in my case not all attributes are the same, so I can't use that application.



TEST.7z 1.98 MB · 3 downloads


Link to comment
Share on other sites

I amended the test code, removed the call to last row etc.


If you go into VBAMAN and make a DVB can load it. Or do this, it should open a Calc sheet. The paperino is a string and the numbers are just that.

(vl-vbaload "D:\\Acadtemp\\Libre\\test1.dvb")
(vl-vbarun "Test1")






Edited by BIGAL
Link to comment
Share on other sites

Truski, next step is to work out how to do for multiple dwgs but only maintain 1 Libreoffice calc. Even with lisp this is not an easy task, simplest way is to use a script and make a csv file. Just google and you will find many examples.


I will continue to play with Libreoffice calc and try to convert to VL.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...