Python Guide - My First Macro

From The Document Foundation Wiki
Jump to: navigation, search

Return to Index

My first Python Macro in LibreOffice

In your user macros places.

1 import uno
2 
3 
4 def my_first_macro_writer():
5     doc = XSCRIPTCONTEXT.getDocument()
6     text = doc.getText()
7     text.setString('Hello World in Python in Writer')
8     return

If your prefer Calc, so...

1 import uno
2 
3 
4 def my_first_macro_calc():
5     doc = XSCRIPTCONTEXT.getDocument()
6     cell = doc.Sheets[0]['A1']
7     cell.setString('Hello World in Python in Calc')
8     return

Return to Index