1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

LibreOffice マクロを Ubuntu + Basic で作る

Posted at

「LibreOffice マクロを Ubuntu + Python で作る」
https://qiita.com/nanbuwks/items/77d5707b9a2507972676

との比較で、同じことを Basic でやってみます。

環境

  • Ubuntu 22.04 LTS
  • LibreOffice Ubuntu package version: 1:7.3.7-0ubuntu0.22.04.3

IDE を開く

今回は、Calc 上で作業を行います。
「ツール」-「マクロ」-「マクロの編集」で IDE が呼び出せます。
image.png

サンプルプログラム

Pythonと同じように、Calc のセルA1にメッセージを表示してみます。
先程のIDEそのまま、「Standard」の「Module1」に以下のように書いていきます。

REM  *****  BASIC  *****

Sub Main
Dim Doc As Object
Dim Sheet As Object
Dim Cell As Object
Dim ShadowFormat As New com.sun.star.table.ShadowFormat

Doc = ThisComponent
Sheet = Doc.Sheets(0)
Cell = Sheet.getCellByPosition(0,0)

Cell.String = " HelloWorldBasic"
End Sub

緑のプレイボタンで実行できます。

image.png

無事実行できました。

image.png

保管場所

IDEで作ったものは、以下の場所にあるようです。

~/.config/libreoffice/4/user/basic$ tree

├── Standard
│   ├── Module1.xba
│   ├── dialog.xlb
│   └── script.xlb
├── dialog.xlc
└── script.xlc

作ったものは「ツール」-「マクロ」-「マクロを実行」で、以下のように呼び出せます。
image.png

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?