Apso Libreoffice

admin 11/23/2021
  • Article Title: Macros

Andrew's Macros

A chronicle of information on the basic macro language with example scripts by Andrew Pitonyak.

  • www.pitonyak.org (as ODT, as PDF)

LibreOffice Basic Guides

  • OO.o Basic Programmer's guide (odt)
  • StarOffice (Basic) programmer's Tutorial, May 2000
    • StarOffice 8 Programmierhandbuch für BASIC 8, 2005 in german
    • StarOffice 7 Office Suite - Basic Programmierhandbuch, 2003 in german

LibreOffice API

LibreOffice scripts make use of the LibreOffice API , documentation is available at:

Python as a macro language

It is possible to use python as a macro language, more details can be found at this page here:

LibreOffice Python Guides


  • X-Ray Basic macro is displaying API objects and is exploring their content. It also displays most Basic datatypes. Its integration of API documentation for services, interfaces, properties and methods is limited to OpenOffice.
  • Alternative Python script organizer (apso) helps managing Python modules as LibreOffice or OpenOffice libraries.
  • MRI It is not always clear at design time which services a UNO object actually supports. MRI (My Reflection and Introspection) displays the properties, methods, services, interfaces which are provided by an object variable.

Lanedo Labs (archived)

Code Snippets

A set of code snippets in Basic covering many parts of LibreOffice:

The OpenOffice CodeSnippet website had a collection of macros in various scripting languages:

  • http://codesnippets.services.openoffice.org
    • Note - the site is down, but the page is still available through the Wayback Machine⁠ at archive.org.
Retrieved from 'https://wiki.documentfoundation.org/index.php?title=Macros&oldid=362790'

Python standard output file is not available when running Python macros from Tools – Macros - Run Macro... menu. Presenting the output of a module requires the Python interactive console. Features such as input(), print(), repr() and str() are available from the Python shell.

The Alternative Python Script Organizer (APSO) extension eases the edition of Python scripts, in particular when embedded in a document. Using APSO you can configure your preferred source code editor, start the integrated Python shell and debug Python scripts. The development of this project is discontinued in behalf of APSO. The code will still be maintained here solely for educational purposes. GUI writen in python to embed a python script in a LibreOffice Document.

The Alternative Python Script Organizer (APSO) extension offers a msgbox() function out of its apso_utils module.

LibreOffice Basic proposes InputBox(), Msgbox() and Print() screen I/O functions. Python alternatives exist relying either on LibreOffice API Abstract Windowing Toolkit, either on Python to Basic function calls. The latter proposes a syntax that is intentionally close to that of Basic, and uses a Python module next to a Basic module. The API Scripting Framework is used to perform Basic, BeanShell, JavaScript and Python inter-languages function calls.

Apso Libreoffice Download

Python syntax:

MsgBox(txt, buttons=0, title=None)

InputBox(txt, title=None, default=None)



>>> import screen_io as ui

>>> reply = ui.InputBox('Please enter a phrase', default='here..')

>>> rc = ui.MsgBox(reply,)

>>> age = ui.InputBox('How old are you?',)

>>> ui.Print(age)


  • Copy screen_io Python module in My macros within <UserProfile>/Scripts/python/pythonpath,

  • Copy uiScripts Basic module in My macros Standard Basic library,

  • Restart LibreOffice.

screen_io Python module

uiScripts Basic module

Apso Libreoffice Mac

Related Topics