Ask Your Question

Changing the (Base) report filename

asked 2020-01-21 21:55:15 +0100

DeadHandsome gravatar image

updated 2020-01-21 22:26:38 +0100

In Base, I have a simple db setup with a form for entering data. My form has a single press button which opens the current record in a report. From the report (Writer) I usually select File > Send > Email as PDF.

I notice the report has a filename based on the underlying report filename, plus index. I'd like to specify exactly the report filename. Is that possible please?

My database is a simple customer, order type affair. The reports are 'invoices' and so I'd like the Writer document filename to include the invoice number.

My press button macro has access to the invoice ref:

invoice_ref = oForm.getString(oForm.findColumn("invoice_ref"))

I open the report like this:


I tried this but the Name filed is read-only:

nHandle = ThisDatabaseDocument.ReportDocuments.getByName("Invoice") = "Invoice_" + invoice_ref

Also tried perusing the API docs, but got a little lost!

Any help much appreciated.

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted

answered 2020-01-22 04:17:25 +0100

Ratslinger gravatar image


Yes you can do this but it will cost more in potential problems than it is worth. It appears you objective here is to not have to enter in the invoice number when the email is generated. It would be surprising if this wasn't already on the document itself.

You can change a report name in a macro with:

 myReports = ThisDatabaseDocument.ReportDocuments.getByName("YOUR_REPORT_NAME")
 sNewName = "Invoice_" + invoice_ref

Now if this is done, the next time this is run the report name is incorrect. So before changing the name it should be saved and changed back after running the report. Save the name with:

 sName = myReports.Name

But the problems are not over. Reports are saved while LO is open in the /tmp directory and the Registry is also involved. Each time a report is run there is an incremental number appended on to the name. This can probably be overcome by emptying the /tmp directory but not certain as to the repercussions it may have on the Registry.

My suggestion would be to test some of this and see the problems presented. Have done this testing and can't see entering a name manually being tougher than the potential for problems.

edit flag offensive delete link more


Well you answered my question on how to rename the report prior to opening in Writer, so thank you for that. I share your concerns about the automatic index that's appended. I need to decide if I can live with that or like you say, just Save As in Writer and manually name the file/pdf.

DeadHandsome gravatar imageDeadHandsome ( 2020-01-22 22:19:09 +0100 )edit

A thought here, change this line:

sNewName = "Invoice_" + invoice_ref


sNewName = "Invoice_" + invoice_ref + "_"

and the invoice # will remain intact within the underscores. This indexing will occur after the ending underscore. Just a suggestion.

Ratslinger gravatar imageRatslinger ( 2020-01-22 22:28:27 +0100 )edit
Login/Signup to Answer

Question Tools

1 follower


Asked: 2020-01-21 21:55:15 +0100

Seen: 30 times

Last updated: Jan 22