While loading a form using a macro, the form disappears as soon as the macro finishes unless I store a reference to the form definition outside of the subroutine that loads the form. Consider the following code (modified to be shorter than the actual routine).

*****BAD*****
Dim oXXX
Sub LoadForm(sURL$, sFormName$)
 Dim oDBDoc          'The database document that contains the form.
 Dim oFormDef        'com.sun.star.sdb.DocumentDefinition of the form.
 Dim oFormDocs       'The form documents container.
 Dim oFormDoc        'The actual form document.
 Dim oCon            'Database connection.
 Dim oParms() As New com.sun.star.beans.PropertyValue
 Dim oBaseContext    'Global database context service.
 Dim oDataBase       'Database obtained from the database context.

 REM Obtain the Base document, either load it or find an open one.
 oDBDoc = FindComponentWithURL(sURL, True)
 oFormDocs = oDBDoc.getFormDocuments()
 oFormDef = oDBDoc.getFormDocuments().getByName(sFormName)
 oBaseContext = CreateUnoService("com.sun.star.sdb.DatabaseContext")
 oDataBase = oBaseContext.getByName(sUrl)
 oCon = oDataBase.getConnection("", "")
 AppendProperty(oParms(), "OpenMode", "openDesign")
 AppendProperty(oParms(), "ActiveConnection", oCon)
 oFormDoc = oFormDocs.loadComponentFromURL(sFormName, "", 0, oParms)
End Sub
***************

Adding one line causes the form to stay open when the macro finishes.
Add the following line to save the form definition:
 oXXX = oFormDef

Is this a bug that I should report?

--
Andrew Pitonyak
My Macro Document: http://www.pitonyak.org/AndrewMacro.sxw
My Macro Book: http://www.hentzenwerke.com/catalog/oome.htm
Free Info:  http://www.pitonyak.org/oo.php


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to