[Calc] How to reference document name in macro?


sub Export_PDF_customrem ----------------------------------------------------- - Pastebin.com 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?


Using the comments by @PYS 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.

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


Just add it to what you have already:

args1(0).Value = sFile & ".pdf"

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


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.