Ask Your Question

template document for Base forms via assistent (wizard)

asked 2019-09-06 10:38:26 +0200

BaseNewb19 gravatar image

Background: I'm new to LIbreOffice and am having a go at making a db in Base.

Basically, all of my forms have the same design, regardless of the actual functionality or form type. I find the default appearance that I get when generating forms via the assistent (or wizard) hard to read and more or less ugly (small font, ugly background color). I realize the form is generated using a Writer document. It would help me a lot and save me a lot of time if I could default for example to "light blue background, size 14 font, white letters".

It seems according to my internet research that this not possible. Can that be? Can I define a Writer doc to be used as default appearance? Thanks.

edit retag flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted

answered 2019-09-06 20:49:44 +0200

Ratslinger gravatar image


You can create forms from a Writer document in Base using a small macro.

This is published in the document AndrewBase by Andrew Pitonyak found here -> Database access using

Section 2.3.2 deals with creating a form using a macro. While this entails controls as well as the basic form, the end of the routine contains code to convert the Writer document to the Base form.

As mentioned by @Alex Thurgood you can create the form using the GUI (or even directly with Writer). Then Save as .odt as your template.

Here is the macro:

Option Explicit

Sub Main
    dim oProps(2) as new
    dim oDocDef, oFormDocs 
    dim sFormName, sVar as string
    sFormName = InputBox("Please enter name for form:", "Form from Writer Document")
    oFormDocs = thiscomponent.FormDocuments
    If oFormDocs.hasByName(sFormName) Then
        sVar = MsgBox(Chr(10) & "Form " & sFormName & " already exists!" & Chr(10) & Chr(10) & "Yes to overwrite; No to Exit", 132, "Form Already Exists!")
        If sVar = 7 Then Exit Sub
    End If
    oProps(0).Name = "Name"
    oProps(0).Value = sFormName
    oProps(1).Name = "Parent"
    oProps(1).Value = oFormDocs
    oProps(2).Name = "URL"
    oProps(2).Value = convertToUrl("/home/YOUR_DIRECTORY/MyBaseTemplate.odt")
Rem Windows:
    'oProps(2).Value = convertToUrl("C:\YOUR_DIRECTORY\MyBaseTemplate.odt")
    oDocDef = oFormDocs.createInstanceWithArguments("", oProps())
    oFormDocs.insertbyName(sFormName, oDocDef)
    Print "Added " & sFormName & " to the database"
End Sub

Have slightly modified the original code to allow input of the form name you want and an escape if the form name already exists. You only need to change the line with oProps(2).Value = convertToUrl("LOCATION/NAME") to reflect your template.

The macro should be saved in My Macros & Dialogs in a module under Standard. Forms can then be created using this by executing the macro from your main Base screen menu Tools->Macros->Run Macro....

edit flag offensive delete link more


BTW - has no relation with using the Wizard. It's either/or.

Ratslinger gravatar imageRatslinger ( 2019-09-06 23:22:48 +0200 )edit

answered 2019-09-06 11:27:45 +0200

Alex Thurgood gravatar image

It is, from what I understand, hardcoded in the wizard code, unfortunately. It should however be possible to create standalone forms using one of the scripting languages, or even externally, that you could then tailor to your particular needs in terms of db connection and usage.

edit flag offensive delete link more


You can always create your own standalone form manually as well via the GUI, save it as a template, and then use that as the basis for any new forms, and adjust the DB bindings as necessary.

Alex Thurgood gravatar imageAlex Thurgood ( 2019-09-06 11:29:30 +0200 )edit
Login/Signup to Answer

Question Tools

1 follower


Asked: 2019-09-06 10:38:26 +0200

Seen: 33 times

Last updated: Sep 06