I followed the advice on another thread to develop my forms not in base but in writer. For this I saved existing base-forms in .odt format.
My buttons call a macro to open a new form and close the present one. Works in base but in writer I get a error which I do not understand.
*Error> Basic runtime error, Object variable not set
My macro:
REM ***** BASIC *****
Option Explicit
Sub Open1
ThisDatabaseDocument.FormDocuments.getbyname(“StandardObjects”).open
End Sub
Sub Open2( oEv as variant )
'reads sOpenFormName & sCloseFormName separated by a comma from tag of calling button
Dim N1 as Integer
Dim N2 as Integer
Dim xpos as Integer
Dim ypos as Integer
Dim XX as String
Dim sOpenFormName as String
Dim sCloseFormName as String
Dim formsTC as Variant
Dim oConnection As Variant
Dim aProp(1) As New com.sun.star.beans.PropertyValue
XX=oEv.Source.Model.Tag ' get button's form from Additional information on button control
N1=len(XX)
N2=inStr(XX,",")
If N2<>0 Then
sOpenFormName = left(XX,N2-1)
sCloseFormName = right(XX,N1-N2)
Else
sOpenFormName = XX
sCloseFormName = ""
End If
**formsTC = thisComponent.Parent.getFormDocuments**
oConnection = thisComponent.Drawpage.Forms(0).ActiveConnection
aProp(0).Name = "ActiveConnection"
aProp(0).Value = oConnection
aProp(1).Name = "OpenMode"
aProp(1).Value = "open"
If sOpenFormName <> "" Then formsTC.loadComponentFromURL(sOpenFormName, "_blank", 0, aProp())
If sCloseFormName <> "" Then ThisDatabaseDocument.FormDocuments.GetByName(sCloseFormName).close
End Sub
*
The form to be opened is named in “Control-Properties - General - Additional Information” as AM_StaffList,AA_Startpage. Seperated by comma.
My guess is that it has something to do with the way the forms are saved as freestanding writer=documents rather than within the base-structure.