%appdata%\OpenOffice\4\user\Scripts\python
の下に python スクリプトを置くと、OpenOffice アプリの[ツール]→[マクロ]→[マクロの管理]→[Python]の下にマクロとして現れる。
# -*- coding: utf-8 -*- ctx = XSCRIPTCONTEXT.getComponentContext() smgr = ctx.ServiceManager desktop = XSCRIPTCONTEXT.getDesktop() def hello(dummy=None): with open(u"D:\\work\\stdout.txt", "a") as f: print>>f, dir("Hello!") g_exportedScripts = ( hello, )
のようなマクロを定義するとこれを実行できる。
LibreOffice Pythonマクロ 「メッセージボックスの表示」 - Qiitaを参考に createMessageBox
を試してみるが実行時エラー・・・。バージョンかな・・・
と思ったが、 messbox
ではなく messagebox
を使ったらいけた。うぅぅ・・・
OpenOffice( Calc )のMacro(Python)をコマンドラインで実行する等 - QiitaとScripting Framework URI Specification - Apache OpenOffice Wikiを参考に
"D:\Program Files (x86)\OpenOffice 4\program\soffice.exe" "vnd.sun.star.script:test.py$hello?language=Python&location=user"
とかすると、「マイマクロ」をコマンドラインから実行できるので大分捗る。