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

asked 2017-04-12 21:16:35 +0200

Tarskovsky gravatar image

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?

edit retag flag offensive close merge delete

Comments

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.

Regina gravatar imageRegina ( 2017-04-12 22:06:29 +0200 )edit

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 ?

librebel gravatar imagelibrebel ( 2017-04-12 22:40:19 +0200 )edit

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.

Tarskovsky gravatar imageTarskovsky ( 2017-04-13 10:24:25 +0200 )edit

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

librebel gravatar imagelibrebel ( 2017-04-13 12:09:43 +0200 )edit

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
librebel gravatar imagelibrebel ( 2017-04-13 12:11:45 +0200 )edit

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

Tarskovsky gravatar imageTarskovsky ( 2017-04-15 20:22:13 +0200 )edit

You're welcome :)

librebel gravatar imagelibrebel ( 2017-04-15 21:18:09 +0200 )edit