How to enable 'Bars_Hide' Macro

System info:

Version: 7.5.5.2 / LibreOffice Community
Build: caf8fe7424262805f223b9a233
Environment: CPU Threads: 4;OS: Windows 10.0 Build 19405
User Interface: UI render: Skia/Raster; VCL:win
Locale: en.GB (en_GB); UI: en-GB
Misc Calc: threaded
Database HSQLDB Embedded

I have a Macro, supplied as part of a db called Addresses.odb that will hide certain (all?) toolbars when a form is opened. How do I apply/enable that code? I already have a ‘Fullscreen’ Macro assigned to the forms Open Document event. Thanks.

Hi, you can join the two macros or call the second from the first macro.

Sub Fullscreen
...
Call Bars_Hide
End Sub

Sub Bars_Hide
....
End Sub

you assign the first macro to the forms Open Document event

1 Like

Hmmmm. When I do that, (actually with a lower case h) I’m getting a message “BASIC syntax error.
Symbol Bars_hide already defined differently.”

Here is the code for the two Macros. I can’t see that Bars_hide is mentioned anywhere else in the Macro set. The form is called frmSpend_Filter.

Sub Fullscreen(oEvent AS OBJECT)
oFrame = oEvent.Source.CurrentController.Frame
oWin = oFrame.getContainerWindow()
oWin.IsMaximized = true
’ msgbox “Maximized”
Call Bars_hide
End Sub

SUB Bars_hide(oEvent AS OBJECT)
DIM oFrame AS OBJECT
DIM oWin AS OBJECT
DIM oLayoutMng AS OBJECT
DIM aElemente()
oFrame = oEvent.Source.CurrentController.Frame
’ oFrame = StarDesktop.getCurrentFrame()
oFrame.setTitle “frmSpend_Filter”
oWin = oFrame.getContainerWindow()
oWin.IsMaximized = true
oLayoutMng = oFrame.LayoutManager
aElemente = oLayoutMng.getElements()
FOR i = LBound(aElemente) TO UBound(aElemente)
oLayoutMng.hideElement(aElemente(i).ResourceURL)
NEXT
ThisComponent.CurrentController.Sidebar.Visible = False
ThisComponent.CurrentController.ViewSettings.ZoomValue = 200
ThisComponent.CurrentController.ViewSettings.ShowRulers = False
ThisComponent.CurrentController.ViewSettings.ShowParaBreaks = False
END SUB

Try joining them this way

Sub Fullscreen(oEvent AS OBJECT)
DIM oFrame AS OBJECT
DIM oWin AS OBJECT
DIM oLayoutMng AS OBJECT
DIM aElemente()
oFrame = oEvent.Source.CurrentController.Frame
oWin = oFrame.getContainerWindow()
oWin.IsMaximized = true
’ msgbox “Maximized”
oFrame.setTitle “frmSpend_Filter”
oLayoutMng = oFrame.LayoutManager
aElemente = oLayoutMng.getElements()
FOR i = LBound(aElemente) TO UBound(aElemente)
oLayoutMng.hideElement(aElemente(i).ResourceURL)
NEXT
ThisComponent.CurrentController.Sidebar.Visible = False
ThisComponent.CurrentController.ViewSettings.ZoomValue = 200
ThisComponent.CurrentController.ViewSettings.ShowRulers = False
ThisComponent.CurrentController.ViewSettings.ShowParaBreaks = False


End Sub
1 Like

OK, I’ve played with that but it made general changes to my db. Even now, when I’ve unassigned it and commented out the macro code you suggested, my forms aren’t showing the usual toolbars, either in View or Edit mode. I can’t figure out what happened but my forms aren’t showing as they did before. I opened another db (Addresses.odb) and it too is missing toolbars, so something has happened that’s effecting all dbs now. Edit: Worked out that I needed to go to View/Toolbars and reenable them. That macro seems to have made a global change that I didn’t want to happen. I just wanted it to make a change for the one form, not everything.

You have to set the toolbars by macro visible while form document will be closed:

SUB ToolbarsShow(oEvent AS OBJECT)
	DIM oFrame AS OBJECT
	DIM oLayoutMng AS OBJECT
	DIM aElemente()
	oFrame = oEvent.Source.CurrentController.Frame
	oLayoutMng = oFrame.LayoutManager
	aElemente = oLayoutMng.getElements()
	FOR i = LBound(aElemente) TO UBound(aElemente)
		oLayoutMng.showElement(aElemente(i).ResourceURL)
	NEXT
	' Might be it isn't visible again:
	' "private:resource/toolbar/standardbar"
	' "private:resource/statusbar/statusbar"
	ThisComponent.CurrentController.Sidebar.Visible = True
	ThisComponent.CurrentController.ViewSettings.ZoomValue = 100
	ThisComponent.CurrentController.ViewSettings.ShowRulers = True
	ThisComponent.CurrentController.ViewSettings.ShowParaBreaks = True
END SUB
1 Like

Thanks. Let me see if I understand. Are you saying I should use the joined Fullscreen code, mentioned earlier, for when the form opens, then use the ToolbarsShow for when the form closes? So, that way, the Fullscreen code effectively applies to that form only and any subsequent opening of other forms is unaffected. Is that correct?
What Event should I assign the ToolBarsShow Macro to? Perhaps “Document is going to be closed” ?

Yes, its the right event for ToolbarsShow
If toolbars won’t be shown by this prozedure, you could also try to show them by the following:

Sub ToolbarsVisible
 DIM oFrame AS OBJECT
 DIM oLayoutMng AS OBJECT
 DIM i AS INTEGER
 DIM aElemente(5) AS STRING
 oFrame = StarDesktop.getCurrentFrame()
 oLayoutMng = oFrame.LayoutManager
 aElemente(0) = "private:resource/menubar/menubar"
 aElemente(1) = "private:resource/statusbar/statusbar"
 aElemente(2) = "private:resource/toolbar/formsnavigationbar"
 aElemente(3) = "private:resource/toolbar/standardbar"
 aElemente(4) = "private:resource/toolbar/formdesign"
 aElemente(5) = "private:resource/toolbar/formcontrols"
 FOR i = LBound(aElemente) TO UBound(aElemente)
 IF NOT(oLayoutMng.requestElement(aElemente(i))) THEN
 oLayoutMng.createElement(aElemente(i))
 END IF
 oLayoutMng.showElement(aElemente(i))
 NEXT
 ThisComponent.CurrentController.Sidebar.Visible = True
 ThisComponent.store()
END SUB

1 Like