Base print to PDF question

Win10 64, LO 7.2.7.2 (64), Hsql2.5.1

Hi,

Currently I use a macro to generate a pdf from a report ( from memory an adaptation of a macro byRobert Grosskopf).

The macro is run from a button, runs an existing report, saves a pdf version to a specified folder and name, displays a message box
where the pdf is located and its name after the report is opened.

All working perfectly fine, however I would like to prevent the report from being opened, simply generate the pdf and a message to where it is.

The Base Guide 73 under Macros (Page 471) states -

If, instead of (or in addition to) a print-out, you want a pdf of the document as a security copy, thestoreToURL() method can be used:

Sub ReportPDFstore(oReport As Object)
Dim stUrl As String
Dim arg(0) As New com.sun.star.beans.PropertyValue
arg(0).name = “FilterName”
arg(0).value = “writer_pdf_Export”
stUrl = “file:///…”
oReport.storeToURL(stUrl, arg())
End Sub

Part of this code is included in my current macro which is :

Sub dump2pdf (oEvent as object)
‘Call plswait
Dim iProdId As Integer
Dim oForm As Object
Dim oControl As Object
Dim oObj1 As Object
oButton = oEvent.source.Model
oForm = ThisComponent.Drawpage.Forms.frmCat.frmUrls.getByName(“tcUrls”)
oControl = oForm.getByName(“fk_uid”)
iProdId = oControl.getCurrentValue()
’ msgbox " " & iProdId
oConn = ThisDatabaseDocument.DataSource.getConnection("","")
sSQL = “UPDATE ““tblFilter”” SET ““ucat””= '” & iProdId & "’"
oQuery = oConn.createStatement()
oQuery.executeQuery(sSQL)
sReportname = oButton.tag
sTimestamp = format (date(),“DDMMYYYY”) + “" + format (time(),“HHMM”)
surlfolderDB = replace(thisdatabasedocument.URL,thisdatabasedocument.title,"")
surlfolder = surlfolderDB+“PDFs/”
if not FileExists (surlfolder) then mkdir surlfolder
sFilename = “”+sReportname+"
”+sTimestamp+"_"+".pdf"
surl = surlfolder+sFilename
if FileExists (surl) then
if msgbox (""""+sFilename+""“ya existe, reemplace?”,49,“pdf Export”) = 2 then exit sub
endif
oReportDocuments = thisdatabasedocument.reportdocuments
oreport = oReportDocuments.getbyname(sReportname).open
dim pdfProperties(1) as new com.sun.star.beans.PropertyValue
dim odtProperties(0) as new com.sun.star.beans.PropertyValue
pdfProperties(0).Name = “FilterName”
pdfProperties(0).Value = “writer_pdf_Export”

oreport.storeToURL(surl, pdfProperties())
msgbox ("Carpeta: "+convertfromurl(surlfolder)+chr(13)+"Archivo: "+sFilename,64,"Informe guardado como .pdf") 

end sub

So the question is is it possible to adjust my current macro so that it does not open the report or open and close it invisible ?

Thank you for your guidance

The report must be opened, because the report creates the *.odt-document, which should now be saved as *.pdf.

p. 469 of the Base Guide:

oReportView = oReport.CurrentController.Frame.ContainerWindow
oReportView.Visible = False

This should be included after:

p. 470 at the end of SUB PrintCloseReport

 oReport.close(true)

should be added after *.pdf has been created - at the end of the procedure.

1 Like

Thanks Robert, just a brief flicker left, can live with that.