Macro to remove menus and toolbars from form view

I would like forms to be in end user mode, i.e. without any menus or toolbars, just the form controls.

What are the methods to display forms without the menus and toolbars?

You can also eliminate menus and toolbars without going full screen with:

Sub HideAllMenuToolbars
   Dim xCurrentController as Object
   Dim xLayoutManager as Object
' If Design mode, just exit the routine and display standard menu and toolbars'
   xCurrentController = thisComponent.CurrentController
   If xCurrentController.isFormDesignMode Then
	   Exit Sub
   End If
   xLayoutManager = thisComponent.CurrentController.Frame.LayoutManager
   xLayoutManager.visible = false
End Sub

Attach to the forms Open Document event in Tools Customize. Routine allows menus and toolbars to be displayed when editing the form.

1 Like

@Ratslinger - My edit is only to add ' at the end of comment line (not necessary for basic but here yes)

I think you proposal is better (closer to the question).


@PYS Thank you - I didn’t know how to correct that.

I was happy to source your code after many googeling :slight_smile: I entered your code and received this Error Message: BASIC runtime error. Property or method not found: isFormDesignMode.
I supose there is a library missing. Could you please let me know what library needs to be installed in order to avoid this error. It seems that the method isFormDesignMode is not existing somehow.

Thanks in andvance, regards Martin

@Martin17 The problem you are encountering is because the code needs to be executed from the form and not directly from the Basic IDE. You can attach it to a button, run it from the menu (Tools->Macros->Run Macro...) or, as the answer states,attach it to the open document event.

What If I wanted to remove all toolbars except for the one I created where I put the necessary commands for this document. Let’s say I called it myToolbar

this is working but how to make it when open extenal file

Doesn’t matter if it is an form inside Base or Stand alone Writer document. Just attach to Open Document event. Read at least some of the documentation.

Got it! Thanks!


Menu Viewâ–¸Full Screen (Ctrl+Shift+J)

If needed you can start this macro when loading the form:

Sub FullScreen
   oDoc = ThisComponent   
   oDocCtrl = oDoc.getCurrentController()
   oDocFrame = oDocCtrl.getFrame()
   cDispatchUrl = ".uno:FullScreen"
   oDispatchHelper = createUnoService( "" )
   oDispatchHelper.executeDispatch( oDocFrame, cDispatchUrl, "", 0, Array() )
End Sub