I use LO 4.3.3.2 in French on Debian Jessie also in French and try to add a report and formatted fields in it using a macro.
I used createunoservice function to create my objects but it didn’t work. That is to say I get no errors but it doesn’t work. I ask this question everywhere on Internet and get no answers. I don’t know whether it is difficult or not to do.
Here is what I did:
REM ***** BASIC *****
Option Explicit
sub createReport
dim oConnection as object
dim oReportsDocuments as object
dim oReportDesign as object
dim oField as object
oConnection = ThisDatabaseDocument.DataSource.getconnection("","")
oReportsDocuments = ThisDatabaseDocument.ReportDocuments
'trying to create a new report
oReportDesign = createUnoService("com.sun.star.report.ReportDefinition")
oReportDesign.setPropertyValue("ActiveConnection", oConnection)
oReportDesign.Command = "Table1"
oReportDesign.Name = "monrapport"
oReportDesign.caption = "legende"
'oReportDesign.setparent(oReportsDocuments)
'trying to add a new formatted field
oField = createUnoService("com.sun.star.report.FormattedField")
with oField
.name = "field1"
.DataField = "field:[champ1]"
'.positionX = 14000 REM marche pô (pas d'erreur mais pas pris en compte)
'.positionY = 0 REM marche pô
.width = 2000
.height = 500
end with
oReportDesign.detail.add(oField)
'trying to add it to the reports
oReportsDocuments.insertbyname("monrapport", oReportDesign)
end sub
Thanks for your help.