You listed two options that seem suitable to you. In fact, the code for the first option has been around for a very long time and still works.
Sub openDefaultForm( )
Const MAIN_FORM_NAME = "YourMaimFormName"
Dim ObjTypeWhat As Variant
Dim oDoc As Variant
ObjTypeWhat = com.sun.star.sdb.application.DatabaseObject.FORM
If ThisDatabaseDocument.FormDocuments.hasbyname(MAIN_FORM_NAME) Then
ThisDataBaseDocument.CurrentController.Connect()
oDoc = ThisDatabaseDocument.CurrentController.loadComponent(ObjTypeWhat, MAIN_FORM_NAME, FALSE)
setVisibleMainWindow(False)
Else
MsgBox "Something happened to the " & MAIN_FORM_NAME & " form!"+ chr(10)+"You deleted? Or renamed?" , 48, "Form not found"
End if
End Sub
Sub setVisibleMainWindow(bVisible As Boolean)
ThisDataBaseDocument.getCurrentController().getFrame().getContainerWindow().setVisible(bVisible)
End Sub
Sub beforeClose(oEvent As Variant)
setVisibleMainWindow(True)
End Sub
I’m not sure that the second option can be implemented. Is it possible that the same macro will be called on the command line?
There is actually another option and it is very popular. @Villeroy came up with a script that will split your project into separate forms and the database itself. The user does not need to make seven clicks - the user will simply open the desired Writer document (the desired form) and start working.
Also see here