storeToURL method not found when exporting report as PDF

I have the following code:

report = thiscomponent.parent.ReportDocuments.getByName("tasks")
report.open
dim aFilterData(0) As New com.sun.star.beans.PropertyValue
aFilterData(0).Name = "FilterName"
aFilterData(0).Value = "writer_pdf_Export"
report.storeToURL("file:///C:/users/david/desktop/tasks.pdf", aFilterData)

The report renders fine but storeToURL generates the following error:

BASIC runtime error.
Property or method not found: storeToURL.

Maybe the open report is not a document that can be saved?

I was on the right track. The report open() function returns a document and I have to save that instead of the report directly. With modification:

dim report as object, document as object
report = thiscomponent.parent.ReportDocuments.getByName("tasks")
document = report.open
dim aFilterData(0) As New com.sun.star.beans.PropertyValue
aFilterData(0).Name = "FilterName"
aFilterData(0).Value = "writer_pdf_Export"
document.storeToURL("file:///C:/users/david/desktop/tasks.pdf", aFilterData)
document.close(true)

Changed to document.close pursuant to @mikekaganski

1 Like

Better use document.close - it is much clearer, and does not depend on ThisComponent automatic behavior.

1 Like