Ask Your Question

Macro to remove all menus and toolbars except for the toolbar I created for my document

asked 2018-05-07 16:35:36 +0200

mlwn gravatar image

I have crossed the question below, and the solution works well:

The only thing is that, I would like to remove all Toolbars except for the toolbar I created for my Document. How can I locate that toolbar and reshow it after hiding all toolbars..

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted

answered 2018-05-07 19:15:05 +0200

Ratslinger gravatar image


This is a response to comment submitted on other post & question here.

The solution is available in the following document -> Andrew's Macro Information and the following code was generated from some of the listings in Section 5.44 Toolbars.

To get a list of the toolbars in the current document:

Sub ListFrameElements
    Dim oDoc, oFrame
    Dim oCfgManager
    Dim oToolInfo
    Dim x
    Dim s$
    Dim iToolType as Integer
    oDoc = ThisComponent
    REM This is the integer value three.
    iToolType =
    oFrame = oDoc.getCurrentController().getFrame()
    oCfgManager = oDoc.getUIConfigurationManager()
    oToolInfo = oCfgManager.getUIElementsInfo( iToolType )
    For Each x in oFrame.LayoutManager.getElements()
        s = s & x.ResourceURL & CHR$(10)
    MsgBox s, 0, "Toolbars in Component"
End Sub

Once you have the list you can hide what you want:

Sub HideRevealFrameObjects
   Dim xCurrentController as Object
   Dim xLayoutManager as Object
   xCurrentController = thisComponent.CurrentController
Rem If in design mode just exit routine
   If xCurrentController.isFormDesignMode Then
       Exit Sub
   End If
   doc = ThisComponent
   frame = doc.CurrentController.Frame
   lmgr = frame.LayoutManager
Rem Now set each item to be hidden (or revealed)
Rem Standard toolbar to be hidden
Rem Standard toolbar to be revealed (would do if previously hidden)
'   lmgr.showElement("private:resource/toolbar/standardbar")  '
End Sub

If this answers your question please tick the ✔ (upper left area of answer). It helps others to know there was an accepted answer.

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower


Asked: 2018-05-07 16:35:36 +0200

Seen: 102 times

Last updated: May 07 '18