Access my report from "My Macros" Library

Hi everyone, I have a push button on my Libreoffice Base form that opens the report. Through the code below I can open the report (which is in the document’s macro library).

ocontroller = Thisdatabasedocument.currentController
if not ocontroller.isconnected then ocontroller.connect
oreportdoc = Thisdatabasedocument.reportdocuments.getbyname("MyReport").open

However, I would like to save the above macro in the “My Macros” Library and access it from My Macros.
How can I do this?
Thank you very much in advance!


Access is very much the same as noted in past question. You may be interested in some documentation links found in this post → To learn LibreOffice Base are there introductions or tutorials?

Aside from macro documentation you can use tools such as MRI or Xray to examine objects.

For your code:

Sub OpenRpt
    sDBName = "Registered Name or File Location"
	oContext = CreateUnoService("")
	oDB = oContext.getByName(sDBName)
	oConn = oDB.getConnection("","") 
    oParent = oConn.getParent()
    oDatabaseDocument = oParent.DatabaseDocument
    oreportdoc = oDatabaseDocument.reportdocuments.getbyname("REPORT_NAME_HERE").open
End Sub

Thank you so much Ratslinger! I am studying StarBasic language daily. However, the small amount of material for Libreoffice Base in my language (Brazilian Portuguese) delays my learning. But, little by little I get there.


It is not really about studying StarBasic. That is fairly simple. The major issue is the API. This is the guts for macros. An object inspector (mentioned MRI, my preference, or Xray) is essential to discovering settings and methods. It assisted me in quickly answering this question. Of course it takes some time in becoming familiar with its use and finding your way around using it.

Also some of the pointed to documentation is really reference material (Pitonyak items are extremely useful). Sorry but it is basically in English.