Calling basic libraries in python to Open Microsoft Excel

Good Afternoon,

I would like to know how I can call GlobalScope.BasicLibraries.loadLibrary(“Tools”) from within python. My goal is to open an Excel (xlsx) file through python in a manner similar to what is described in
How to open MS excel file in Libre office macro - English - Ask LibreOffice

Thank you for your assistance.

Calling Basic Macros from Python

thank you very much. i will take a look at this.

Why Basic? Just open the file in Python.

import uno
gPathName = '/tmp/test/DDE_Source.ods'

def test_OpenFile():
    url = uno.systemPathToFileUrl(gPathName)
    ctx = XSCRIPTCONTEXT.getComponentContext()
    smgr = ctx.ServiceManager
    dtp = smgr.createInstance('com.sun.star.frame.Desktop')
    doc = dtp.loadComponentFromURL(url, '_default', 0, ())
2 Likes

So using this code I can open Excel? I am away from a computer presently.

The same code with another path name can open Excel documents (not Excel itself).

1 Like

Yes. Sorry for being vague. Excel documents.

Yes it works. Thank you for your assistance.