| View previous topic :: View next topic |
| Author |
Message |
keithclark1966 OOo Enthusiast

Joined: 18 Jan 2007 Posts: 189
|
Posted: Fri Dec 05, 2008 9:20 am Post subject: Call a report from a form |
|
|
Is there a way to print a report from within a form?
Keith _________________ Open Office 3.0 under Ubuntu 9.04, XP and Vista |
|
| Back to top |
|
 |
RPG Super User

Joined: 24 Apr 2008 Posts: 2696 Location: Apeldoorn, Netherland
|
Posted: Fri Dec 05, 2008 2:52 pm Post subject: |
|
|
Hello
This sub can open a report and print the report to the default printer. I don't know if it is possible to do ask for which printer.
this links tell something about uno:print.
http://www.oooforum.org/forum/viewtopic.phtml?t=6049
http://www.oooforum.org/forum/viewtopic.phtml?t=76847&highlight=uno+print
http://www.oooforum.org/forum/viewtopic.phtml?t=70190&highlight=uno+print
I knew it is working with OOo 3.0 but I cannot test it for lower version. And I think that the loadComponent methode is not working with OOo2.3 and lower
Romke
| Code: | sub openform_report
' First try to make compatible OO3.0 with ThisdatabaseDocument and Thiscomponent
dim oThisDatabaseDocument ' I do use this
' first I think this is a solution for Open Office lower then OOo3.0
if GetSolarVersion=300 then
' I do get this number with OOo3.0
oThisDatabaseDocument=ThisDatabaseDocument
else
oThisDatabaseDocument=thiscomponent.parent
end if
'for information look here
'http://api.openoffice.org/docs/common/ref/com/sun/star/sdb/application/XDatabaseDocumentUI.html
' I think that this line can test if object has the good sevice.
if not HasUnoInterfaces(oThisDatabaseDocument.CurrentController,"com.sun.star.sdb.application.XDatabaseDocumentUI") then
print "Your version of Open Office does not have this capabillities"
end if
dim oCurrentController
oCurrentController=oThisDatabaseDocument.CurrentController
dim sNewfileReportName ' This is the name how it is in the database
dim oNewReportSee ' Object for the new form wat will beopend
sNewfileReportName="testquery" 'is a write form I think it must be in this database
'http://api.openoffice.org/docs/common/ref/com/sun/star/sdb/application/XDatabaseDocumentUI.html
'http://api.openoffice.org/docs/common/ref/com/sun/star/sdb/application/DatabaseObject.html
'http://api.openoffice.org/docs/common/ref/com/sun/star/sdb/XSQLErrorBroadcaster.html#addSQLErrorListener
'com.sun.star.sdb.application.DatabaseObject.FORM ' use this for form
'com.sun.star.sdb.application.DatabaseObject.REPORT ' use this for report
' there are two form of the command
oNewReportSee=oCurrentController.loadComponent( com.sun.star.sdb.application.DatabaseObject.REPORT,sNewfileReportName,FALSE) ' or TRUE for editing the document
' The next code acts on the report
dim document,dispatcher
'document = ThisComponent.CurrentController.Frame
document = oNewReportSee.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
rem ----------------------------------------------------------------------
dim args4(1) as new com.sun.star.beans.PropertyValue
' This print to the default printer whithout any question
args4(0).Name = "Copies"
args4(0).Value = 1
args4(1).Name = "Collate"
args4(1).Value = true
dispatcher.executeDispatch(document, ".uno:Print", "", 0, args4())
end sub |
I think that this values are all possible in the array
MakePropertyValue( "Copies", 1 )
MakePropertyValue( "Selection", True )
MakePropertyValue( "Collate", False ) |
|
| Back to top |
|
 |
MSPhobe Super User

Joined: 29 Sep 2005 Posts: 529 Location: England
|
Posted: Sat Dec 06, 2008 5:48 am Post subject: |
|
|
Forgive me talking about something I don't know about... but this sounds like it might be the sort of thing "Switchboard" is for.
I hope Switchboard experts will comment... |
|
| Back to top |
|
 |
keithclark1966 OOo Enthusiast

Joined: 18 Jan 2007 Posts: 189
|
Posted: Sat Dec 06, 2008 8:33 am Post subject: |
|
|
Switchboard? _________________ Open Office 3.0 under Ubuntu 9.04, XP and Vista |
|
| Back to top |
|
 |
MSPhobe Super User

Joined: 29 Sep 2005 Posts: 529 Location: England
|
Posted: Sat Dec 06, 2008 2:34 pm Post subject: |
|
|
See Tools | Extension Manager, and filter by application.
"Generates a... (menu) interface to access Base forms and reports." |
|
| Back to top |
|
 |
|