[Solved] Accessing database documents via Basic

Creating a macro - Writing a Script - Using the API

[Solved] Accessing database documents via Basic

Postby Hacker John » Thu Dec 06, 2007 1:20 pm

I'm struggling with the documentation to find a way of opening forms and reports using OpenOffice Basic code. Does anyone have examples or can point me towards some docs/web pages?

Thanks in advance.
Last edited by Hacker John on Fri Jan 04, 2008 12:17 am, edited 1 time in total.
Hacker John
 
Posts: 25
Joined: Thu Dec 06, 2007 1:17 pm

Re: Accessing database documents via Basic

Postby QuazzieEvil » Thu Dec 06, 2007 5:36 pm

you can goto http://www.geocities.com/rbenitez22 and goto the OpenOffice.org link.
QuazzieEvil
Volunteer
 
Posts: 283
Joined: Tue Dec 04, 2007 6:38 pm
Location: Houston, TX

Re: Accessing database documents via Basic

Postby Hacker John » Fri Dec 07, 2007 5:15 pm

Thanks for the link - the docs look quite comprehensive. OO basic is a tad more difficult than Microsoft Office VBA but I'm sure I'll get there.
Hacker John
 
Posts: 25
Joined: Thu Dec 06, 2007 1:17 pm

Re: Accessing database documents via Basic

Postby Hacker John » Thu Jan 03, 2008 3:54 am

I've had a look through umpteen documents but still no joy. I basically want to open a report by pressing a button in a form. I also want to be able to open forms from other forms. Does anyone know how to do this?
Hacker John
 
Posts: 25
Joined: Thu Dec 06, 2007 1:17 pm

Re: Accessing database documents via Basic

Postby QuazzieEvil » Thu Jan 03, 2008 5:20 am

Code: Select all   Expand viewCollapse view
Sub OpenForm(Event As Object)
   Dim Form As Object
   Dim FormDoc AS Object
   Dim FormCollection As Object
   Dim DBDoc As Object
   Dim NewForm As Object
   Dim NewFormDoc As Object
   Dim Args(2) As New com.sun.star.beans.PropertyValue
   
   Form=Event.Source.Model.Parent REM CODE BOUND TO FORM BUTTON
   FormCollection=Form.Parent
   FormDoc=FormCollection.Parent   
   DBDoc=FormDoc.Parent

   Args(0).Name="ActiveConnection"
   Args(0).Value=Form.ActiveConnection
   Args(1).Name="OpenMode"
   Args(1).Value="open"
                docName="EMPLOYEES" REM CHANGE TO YOUR FORM/REPORT NAME
   REM TO OPEN FORM DO
               NewFormDoc=DBDoc.FormDocuments.loadComponentFromURL(docName,"_blank",0,Args())
              REM TO OPEN REPORT DO
              NewRerpotDoc=DBDoc.ReportDocuments.loadComponentFromURL(docName,"_blank",0,Args())
End Sub
QuazzieEvil
Volunteer
 
Posts: 283
Joined: Tue Dec 04, 2007 6:38 pm
Location: Houston, TX

Re: Accessing database documents via Basic

Postby Hacker John » Thu Jan 03, 2008 6:13 pm

Many thanks for that code - it worked a treat. I'll pick the bones out of it at my leisure. The only guide to the object model seems to be in Java so I assume that the objects are mostly the same in OOBasic.

Thanks again - this has been a great help.
Hacker John
 
Posts: 25
Joined: Thu Dec 06, 2007 1:17 pm


Return to Macros and UNO API

Who is online

Users browsing this forum: No registered users and 8 guests