Ask Your Question

How do I ensure that the LO GUI is minimised on startup

asked 2015-07-17 18:40:15 +0200

jay Arr gravatar image

updated 2020-07-12 20:25:39 +0200

Alex Kemp gravatar image

Using LO v4.4.4.3 with OSX 10.10.4 & Windows 7 & Ubuntu 15.04

I'm developing a LO database application and want to keep LO in the background well away from my users. who will be *poets and writers * - who will be not especially IT/database literate.

My aim is that when a user clicks on the application's .obd file (s)he will will see the start up LO screen and then the next thing they will see is my announcing application's splash screen shortly followed by the controlling switchboard. I.E. they will NOT see the LO GUI which would expose the application's tables, queries, forms & reports and simply confuse and distract them.

I'm guessing that I can't bypass the GUI completely (am I correct?) so I'd like my startup macro - which already established the database connection and fires the application - to minimise the GUI and banish it to the task bar.

The application is self contained; it has it's own exit which automatically shuts down the db connection and terminates LO and it has it's own error report log which the user will be able email back to me.

So, my question is:

"What lines of Basic code to I need to have the GUI automatically minimised on startup?"

edit retag flag offensive close merge delete

3 Answers

Sort by » oldest newest most voted

answered 2015-07-17 19:34:57 +0200

Alex Kemp gravatar image

updated 2015-07-17 19:37:44 +0200

Examine the soffice startup options. I show the headline ones below on my system ("--invisible" + "--minimized" are two obvious ones) but there are a lot more:

:~$ /opt/libreoffice4.4/program/soffice.bin --help
LibreOffice 2c39ebcf046445232b798108aa8a7e7d89552ea8

Usage: soffice [options] [documents...]

--minimized    keep startup bitmap minimized.
--invisible    no startup screen, no default document and no UI.
--norestore    suppress restart/restore after fatal errors.
--quickstart   starts the quickstart service
--nologo       don't show startup screen.
--nolockcheck  don't check for remote instances using the installation
--nodefault    don't start with an empty document
--headless     like invisible but no userinteraction at all.
--help/-h/-?   show this message and exit.
--version      display the version information.
--writer       create new text document.
--calc         create new spreadsheet document.
--draw         create new drawing.
--impress      create new presentation.
--base         create new database.
--math         create new formula.
--global       create new global document.
--web          create new HTML document.
-o             open documents regardless whether they are templates or not.
-n             always open documents as new files (use as template).

If this helps then please tick the answer (✔).

edit flag offensive delete link more


Thanks for this very prompt help.

jay Arr gravatar imagejay Arr ( 2015-07-17 22:39:24 +0200 )edit

that's a nice option. I have been using the method .SetVisible(False) on startup on the .CurrentController.Frame.ContainerWindow but there still is a second on startup where the gui appears. I'll try --invisible out.

doug gravatar imagedoug ( 2015-07-18 05:43:16 +0200 )edit

Alex, unfortunately the startup option:


does NOT turn off the UI on the MAC.

I\ve also tried other combinations of --minimized & --nologo none of which affect the UI.

Doug could you please explain in a bit more detail how and where to put your solution - thanks

jay Arr gravatar imagejay Arr ( 2015-07-19 12:40:23 +0200 )edit

answered 2015-07-19 15:20:51 +0200

doug gravatar image

An alternate way to make the main database window go away on startup is to create a macro that activates on the Open Document event. The result will that the database window is open for less than a second at startup and then disappears in favor of your switchboard. The principle behind this is easy to implement, but there is bulk added to the solution to avoid some common problems and make it work automatically at startup.

First, you will need to create a new Library in My Macros. Go to Tools-->Macros-->Organize Macros-->My Macros and click the button Organizer and then in the new dialog, click the tab Libraries. Click New and choose a name. Then in the Macro window click New to add a Module to the library. This must be the module you use. This is necessary to allow the macro to be invoked from a document-level macro.

Second, create a subroutine in the module. Here is the annotated subroutine. The key part is the SetVisible(False):

REM  '*****  BASIC  *****'

Sub HideDBWinOpenSwitchboard

  REM 'catch any error to give alternate instructions to user'

  On Local Error Goto ErrHandOpenDB

  REM 'if applied to the `Open Document` event `ThisComponent` is equivalent to `ThisDatabaseDocument`'
  REM 'the difference being `ThisComponent` works'

  tc = ThisComponent

  REM 'this loop is to work around a delay in defining `ThisComponent` by LO'

  i = 1
  Do Until InStr(tc.dbg_properties, "CurrentController" ) > 0 Or i  >= 70
    Wait 5
    tc = ThisComponent
    i = i + 1

  REM 'work around more LO limitations when atteming to run on `Open Document` event'


  tc.Title = "Title that is displayed at the top of the window and can be used in form titles"

  REM 'here is the object hierarchy to get to the database window'

  cntrllr = tc.CurrentController

  REM 'belt and suspenders, this might not be necessary'

  If cntrllr.isConnected = False Then 
  End If

  REM 'more of the object hierarchy'

  frm = cntrllr.Frame
  appWindow = frm.ContainerWindow

  REM 'make main application window disappear'

  appWindow.IsMaximized = False

  REM 'FYI this is the window inside the application window, if can be resized independently'
  REM 'but have not seen any use for this yet'

  REM comWin = frm.ComponentWindow

  REM 'open switchboard form'

  FrmContainer = tc.FormDocuments.getByName("switchboard")

  rootFrm = FrmContainer.Component.getDrawPage.getForms
  rootDoc = rootFrm.parent
  ctrllr = rootDoc.CurrentController
  frm = ctrllr.Frame

  REM 'apply title of database set forth above plus title of form'

  frm.Title = tc.Title & ": switchboard"

  REM 'maximize the switchboard window'

  frmWindow = frm.ContainerWindow
  frmWindow.IsMaximized = True

  REM 'FYI again here is the window inside the form window'
  REM frmComp = frm.ComponentWindow

  REM 'adjust zoom of switchboard'

  ctrllr.ViewSettings.ZoomValue = 90

  Exit Sub

  MsgBox "The intro did not go as planned.  Browse to `Forms` and open the `Switchboard`."

End Sub

Third, Assign the macro to the Open Document event in your document. My Macros. Go to Tools-->Macros-->Organize Macros: navigate to your macro and then Assign button. Assign the Macro to the Open ... (more)

edit flag offensive delete link more


Doug thanks for this which has the virtue of

a) working (not that I expected it wouldn't)

and vices of b) clobbering my call DBopen - no matter where I put it with inside the macro at the beginning, as the very last statement, outside called before or after - it just wouldn't work!? and c) the very last point you make that there's a significant bug when working with report all of which mean that, unfortunately I can't use it. I've reinstalled LO v4.4.4 to re-experiment with the options

jay Arr gravatar imagejay Arr ( 2015-07-20 16:06:50 +0200 )edit

If you look at the bug report, you'll see there is a sort-of-clumsy workaround for the Reports bug. Provide some more detail on DBopen problem. I would guess the problem is here : tc.connectController(tc.CurrentController). You could try deleting it, although odds are you will run into other problems ....

doug gravatar imagedoug ( 2015-07-20 16:27:50 +0200 )edit

Also, it is assuming ThisComponent is the same as ThisDatabaseDocument based on the event that is called. The latter does not work for me on the Open Document event. However, if calling on a different event, you might use the latter as a troubleshooting step.

doug gravatar imagedoug ( 2015-07-20 16:30:21 +0200 )edit

answered 2017-02-09 10:06:41 +0200

Kridtbandit gravatar image

Try this method, make a dukoment into sets a button and give the name of the form you want to open.

The button execute events to this macro inserted.

    Sub kaldformkanp(oEvent AS OBJECT)
DIM kanp AS Object

kanp = oEvent.source.model

Function openForm(FormName as String) 
   oContext = CreateUnoService("") 
   oFont = oContext.getRegisteredObject("You database") ´remember to register database
   dbForms = oFont.DatabaseDocument.FormDocuments 
   oAConnection = oFont.getConnection("","") 

   Dim pProp(1) As New 
   pProp(0).Name = "ActiveConnection" 
   pProp(0).Value = oAConnection 
   pProp(1).Name = "OpenMode" 
   pProp(1).Value = "open" 

   oForm = dbForms.loadComponentFromURL(FormName, "_blank", 0, pProp()) 
End Function`
edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower


Asked: 2015-07-17 18:40:15 +0200

Seen: 1,637 times

Last updated: Feb 09 '17