A great song from days gone by...and just about how I feel at the moment.
It really should be simple:
Open an embedded Base form from a command line.
And it is, as long as there is something, anything else from
OpenOffice.org open.
For example:-
In a library named cmdLine is this sub procedure:
Sub LoadDBForm( dbName as string, frmName as string )
dim cntxt as variant
dim DB as variant
dim conn as variant
dim frm as variant
dim InteractionHandler as variant
dim ln as integer
dim errMessage as string
Dim aProp(1) As New com.sun.star.beans.PropertyValue
on error goto LoadDBForm_Error
ln = 1
cntxt = CreateUnoService("com.sun.star.sdb.DatabaseContext")
DB = cntxt.getByname( trim(dbName) )
ln = 2
If Not DB.IsPasswordRequired Then
conn = DB.GetConnection("","")
Else
InteractionHandler = createUnoService("com.sun.star.sdb.InteractionHandler")
conn = DB.ConnectWithCompletion(InteractionHandler)
End If
aProp(0).Name = "ActiveConnection"
aProp(0).Value = conn
aProp(1).Name = "OpenMode"
aProp(1).Value = "open"
ln = 3
frm =
DB.DatabaseDocument.FormDocuments.loadComponentFromURL(trim(frmName),"_blank",0,aProp())
exit sub
LoadDBForm_Error:
errMessage = error(err) & chr(10)
select case ln
case 1 : errMessage = errMessage & "Could not load datasource: " & dbName
case 2 : errMessage = errMessage & "Invalid UserName or password for: " & dbName
case 3 : errMessage = errMessage & "Could not load form: " & frmName
end select
print errMessage
End Sub
I can call that macro then with a command of
soffice -invisible "macro:///cmdLine.Module1.LoadDBForm( "Clinic" ,
"Swtichboard" )"
Now if quickstarter is running, or any openoffice.org documentx are
opened when that command line is executed the form Swtichboard opens and
is ready to go.
But if there is NOT some OTHER document already opened, and quickstarter
is not running, then the form opens for a brief moment, data never fills
the controls and it simply closes - no error is generated.
The question is not really why...the question is for how much longer?
How much longer before Base gets taken off of the whipping post and
becomes a full fledged citizen of the OpenOffice.org application and no
longer considered merely 3/5ths of a module?
By the way here is a nasty kludge - add this to the beginning of the
procedure
Sub LoadDBForm( dbName as string, frmName as string )
dim cntxt as variant
dim DB as variant
dim conn as variant
dim frm as variant
dim InteractionHandler as variant
dim ln as integer
dim errMessage as string
dim tmpDoc as variant
Dim aProp(1) As New com.sun.star.beans.PropertyValue
on error goto LoadDBForm_Error
aProp(0).Name = "Hidden"
aProp(0).Value = true
tmpDoc = starDesktop.loadcomponentfromURL( "private:factory/swriter", "_blank",
0, aProp() )
ln = 1
cntxt = CreateUnoService("com.sun.star.sdb.DatabaseContext")
----------------------------
Now everything works fine - with one small problem - so now we need to
setup a way to close that hidden form when our last working form for the
dataabase is closed...
Drew
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]