Ask Your Question

[Calc] How to reference document name in macro?

asked 2019-11-11 19:07:30 +0100

Boggle gravatar image

updated 2020-10-28 12:50:13 +0100

Alex Kemp gravatar image

LibreCalc here is my pdf macro.

I wish for it to reference the document name instead of some predetermined, "hard coded" name that is in the macro.

How do I reference the document name here?

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted

answered 2019-11-11 23:09:32 +0100

Ratslinger gravatar image


Using the comments by @pierre-yves samyn in this post -> how i display current file name only in open office 2.0 using macro (display on msg box) you can obtain in a variety of results.

First load the library:


To simply get the file name without directories or extension:

sFile = FileNameoutofPath(GetFileNameWithoutExtension(ThisComponent.getLocation()))

To get full path without file extension:

sFile = GetFileNameWithoutExtension(ThisComponent.getLocation())

Refer to the post and library for others.

edit flag offensive delete link more

Comments here is my edited macro. It produces a pdf file, but the file is extension-less. How do I make it output with .pdf ?

Boggle gravatar imageBoggle ( 2019-11-13 15:27:59 +0100 )edit


Just add it to what you have already:

args1(0).Value = sFile & ".pdf"
Ratslinger gravatar imageRatslinger ( 2019-11-14 20:19:37 +0100 )edit

Thanks! That worked. I'm still trying to learn macros in this. From what I understand libreoffice uses a variant of MS basic? Thanks again

Boggle gravatar imageBoggle ( 2019-11-14 23:19:09 +0100 )edit


Unfortunate time delay. Was out for a few days and notifications on this site are not working completely at least for me.

No, it is not a variant. It uses StarBasic. Info -> OpenOffice Basic. Also -> Tutorial. For more just Google StarBasic.

Ratslinger gravatar imageRatslinger ( 2019-11-15 02:53:50 +0100 )edit
Login/Signup to Answer

Question Tools

1 follower


Asked: 2019-11-11 19:07:30 +0100

Seen: 568 times

Last updated: Nov 11 '19