[Solved] Report builder automatic saving & opening as Report

Discuss the database features
Post Reply
juergen_1987
Posts: 16
Joined: Mon Jan 16, 2012 9:00 pm

[Solved] Report builder automatic saving & opening as Report

Post by juergen_1987 »

Hy,

i use the reportbuilder to create some reports. Is it possible to automatic store the report as Pdf (with a macro) and open the pdf file?


I have a macro to open a file:
http://en.libreofficeforum.org/node/6842

Code: Select all

' sFile = "path\filename"
sub OpenDocument(sFile)
  oSer = createUNOService("com.sun.star.system.SystemShellExecute")
  oSer.execute(sFile,,0)
end sub
so i need a code to store a report as pdf in a path. can you help me or do you know any similar code?
Last edited by juergen_1987 on Mon Aug 10, 2015 10:29 am, edited 3 times in total.
OpenOffice 4.1.1 and Libreo. 4.4.x on Windows 7
User avatar
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Report builder automatic saving and opening as Report

Post by Villeroy »

Yes, it is possible.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
juergen_1987
Posts: 16
Joined: Mon Jan 16, 2012 9:00 pm

Re: Report builder automatic saving and opening as Report

Post by juergen_1987 »

I found a nice discripton to create a PDF in a german forum.
http://de.openoffice.info/viewtopic.php ... 3&start=15 the last post of ejomi (second last entry)
The link to the Tutorial "API/Tutorials/PDF export"
https://wiki.openoffice.org/wiki/API/Tu ... PDF_export

i will have to decide where i want to use this function.
OpenOffice 4.1.1 and Libreo. 4.4.x on Windows 7
juergen_1987
Posts: 16
Joined: Mon Jan 16, 2012 9:00 pm

Re: Report builder automatic saving and opening as Report

Post by juergen_1987 »

Now i solved this problem.
Here is an example how you can open a report and generate a PDF. The function ExportPDF is from german forum (link from to function is in the post above).
I have changed a little thing. Now I don't open the report as pdf.

Code: Select all

' FROM: http://www.oooforum.org/forum/viewtopic.phtml?t=65111
sub OpenBerichtsabfrage2()
	OpenReport("berichtabfrage-de" )
       ExportPDF
end sub


sub OpenReport(sReportName as string)	
	Dim aProp(1) As New com.sun.star.beans.PropertyValue
	aProp(0).Name = "ActiveConnection"
	aProp(0).Value = connection 'GetConnection
	aProp(1).Name = "OpenMode"
	aProp(1).Value = "open"   'http://www.openoffice.org/api/docs/common/ref/com/sun/star/sdb/DocumentDefinition.html
	thisComponent.Parent.getReportDocuments.loadComponentFromURL(sReportName,"_blank",6,aProp())	'_blank,6
end sub
OpenOffice 4.1.1 and Libreo. 4.4.x on Windows 7
Post Reply