自信なし。解決策ではなく原因推測で終わる回答になってしまってもいる。
以下、あまり役に立たないかもしれない実験。
' 当方Windows 10 + LibreOffice 5.1.2 x64
Sub Main
Dim x
x = StarDesktop.CurrentComponent
MsgBox(x.GetURL())
End Sub
をF8でステップ実行。最後まで走る前にウォッチウィンドウ(でいいのかな?MS Office付属のVBA的にはそう呼ぶけど)にxを入力してEnter。ちなみに変数名は入力できるが、プロパティ名や式を入力しても意味が無い。で、xの型がcom.sun.star.comp.basic.BasicIDEになってしまっていることを確認。
少なくともBasic IDE上で実行したり、シート上にボタンコントロール等を配置してイベントを発動させても上記コード
で空文字列になっていることから、同様の状況になっていると考えられる。(追記:この挙動はマクロ自体が文書に含まれているかMy Macrosに入っているかに依存しないようだ。下記URLの説明と合わせて正直よくわからんのだが。)
一方、BasicIDEではなく、例えば、Calc自体のメニューから、Tools->Macros->Organize Macros->LibreOffice Basicを選択して、表示されたダイアログの右上にあるRunボタンから実行した時には、(俺はodsファイルで実験していたのだが)そのodsファイルの位置が表示された。
役に立つかもしれない参考資料:
https://wiki.openoffice.org/wiki/Docu...
As previously mentioned, ThisComponent is used from document Basic, but it is also possible to use it from application Basic. In an application wide Basic module, ThisComponent is identical to the current component that can also be accessed through StarDesktop.CurrentComponent. The only difference between the two is that if the BasicIDE is active, StarDesktop.CurrentComponent refers to the BasicIDE itself while ThisComponent always refers to the component that was active before the BasicIDE became the top window.