Ask Your Question

macro to remove menus and toolbars from form view

asked 2016-07-13 15:20:17 +0200

jvglynnjr gravatar image

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?

edit retag flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted

answered 2016-07-13 16:09:20 +0200

pierre-yves samyn gravatar image


Menu ViewFull 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


edit flag offensive delete link more

answered 2016-07-13 16:59:44 +0200

Ratslinger gravatar image

updated 2016-07-14 11:52:10 +0200

pierre-yves samyn gravatar image

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.

edit flag offensive delete link more


@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).


pierre-yves samyn gravatar imagepierre-yves samyn ( 2016-07-14 11:55:14 +0200 )edit

@pierre-yves samyn Thank you - I didn't know how to correct that.

Ratslinger gravatar imageRatslinger ( 2016-07-14 16:25:07 +0200 )edit

I was happy to source your code after many googeling :-) 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 gravatar imageMartin17 ( 2017-08-23 17:24:39 +0200 )edit

@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.

Ratslinger gravatar imageRatslinger ( 2017-08-23 19:04:40 +0200 )edit

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

mlwn gravatar imagemlwn ( 2018-05-07 16:31:25 +0200 )edit
Login/Signup to Answer

Question Tools

1 follower


Asked: 2016-07-13 15:20:17 +0200

Seen: 1,733 times

Last updated: Jul 14 '16