How can I hide the menu bar using a macro on calc?

I have tried some macros after some research on the internet, but it’s not working…
Example:

Sub hideallBars()
   Dim doc As Object
   Dim frame As Object
   Dim lmgr As Object
   Dim LayoutElements(4) As String
   Dim i As Integer
   
   LayoutElements(0) = "private:resource/toolbar/standardbar"
   LayoutElements(1) = "private:resource/toolbar/findbar"
   LayoutElements(2) = "private:resource/toolbar/formatobjectbar"
   LayoutElements(3) = "private:resource/menubar/menubar"
   LayoutElements(4) = "private:resource/statusbar/statusbar"
   
   doc = ThisComponent
   frame = doc.CurrentController.Frame
   lmgr = frame.LayoutManager
   for i = 0 to 4
      lmgr.hideElement(LayoutElements(i))
   next i
End Sub

Any help?

Why do you need a macro? There exist the commands Menubar and Full Screen in category View, which you can use to customize a toolbar or assign a shortcut key.

i can’t see anything wrong in your code …
Since you don’t mention any error message, it seems some other factor is preventing the visual update on your screen. Is the Frame.ComponentWindow visible and enabled? Are the controllers unlocked using ThisComponent.UnlockControllers ?

How can I check if Frame.ComponentWindow is visible or enabled?
or if the ThisComponent.UnlockControllers is unlocked?

I’m not using another code, I’m trying to figure out how to hide the menu bar cause I will port one of my spreadsheets made on excel which uses a lot of VBA macros, so, I’m trying to figure out how to deal with some of the features that my spreadsheet has ans must be included on Calc.

hello Tarskovsky, more info about Frames can be found here, however since you said you’re not using any other code , i doubt if the problem lies there after all…

plz try if this works:

Sub hideallBars()
	Dim LayoutManager, LayoutElements
	Dim i As Integer
	LayoutManager = ThisComponent.CurrentController.Frame.LayoutManager
	LayoutElements = LayoutManager.getElements()
	For i = 0 to Ubound( LayoutElements )
	   LayoutManager.hideElement( LayoutElements(i).ResourceURL )
	Next
End Sub
1 Like

That was exactly what I was looking for. Thank you so much!

You’re welcome :slight_smile: