Form Button to print report

Getting your data onto paper - or the web - Discussing the reports features of Base

Form Button to print report

Postby nusta88 » Fri Jul 25, 2008 3:55 pm

Hello i am from Germany and i look up for an easy solution.

I have a form. I want to print the report by click on the button.

Here is my code:

Code: Select all   Expand viewCollapse view
sub Bericht_drucken
DatabaseContext=createUnoService("com.sun.star.sdb.DatabaseContext")
oDatenquelle = DatabaseContext.getByName("HV")
oDoc = oDatenquelle.DatabaseDocument
oBericht = oDoc.getReportDocuments().getByName("Kunde")
oBerichtDoc = oBericht.getComponent
Props = oBerichtDoc.getPrinter()
sDrucker = Props(0).value               
Dim arg(1) as new com.sun.star.beans.PropertyValue   
arg(0).name = "Name"               
arg(0).value = "<" & sDrucker & ">"      
arg(1).name = "Wait"               
arg(1).value = True                  
oBerichtDoc.print(arg())            
End sub


The program sends an error message, that the object ist not right in this lines:
Code: Select all   Expand viewCollapse view
Props = oBerichtDoc.getPrinter()

Code: Select all   Expand viewCollapse view
oBerichtDoc.print(arg())   

I hope you can help me
Thanks
OOo 3.0.X on Ms Windows XP
nusta88
 
Posts: 4
Joined: Fri Jul 25, 2008 3:46 pm

Re: Form Button to print report

Postby nusta88 » Tue Jul 29, 2008 3:04 pm

I have solved the problem with this code:

Code: Select all   Expand viewCollapse view
oContexto = CreateUnoService("com.sun.star.sdb.DatabaseContext")
oFonte = oContexto.getRegisteredObject("HV")
oReports = oFonte.DatabaseDocument.ReportDocuments
oAConnection = oFonte.getConnection("","")

Dim pProp(1) As New com.sun.star.beans.PropertyValue
pProp(0).Name = "ActiveConnection"
pProp(0).Value = oAConnection
pProp(1).Name = "OpenMode"
pProp(1).Value = "open"

oReport = oReports.loadComponentFromURL("KUNDE", "_blank", 0, pProp())
Props = oReport.getPrinter()
sDrucker = Props(0).value               
Dim arg(1) as new com.sun.star.beans.PropertyValue   
arg(0).name = "Name"               
arg(0).value = "<" & sDrucker & ">"      
arg(1).name = "Wait"               
arg(1).value = True                  
'oReport.print(arg())
If HasUnoInterfacees(oDoc,"com.sun.star.util.XCloseable")then
oReport.close(True)


But i have a problem with closing the report. i cannot help myself. Can anybody help me??
OOo 3.0.X on Ms Windows XP
nusta88
 
Posts: 4
Joined: Fri Jul 25, 2008 3:46 pm


Return to Reporting

Who is online

Users browsing this forum: No registered users and 1 guest