List elements inside custom Toolbar

Hello,

I created a custom toolbar inside Writer and now I have to hide or display some items, depending on a condition inside my macro.

I found a snipped that helps me list the different toolbars, here it is :

    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 = com.sun.star.ui.UIElementType.TOOLBAR
    oFrame = oDoc.getCurrentController().getFrame()
    oCfgManager = oDoc.getUIConfigurationManager()
    oToolInfo = oCfgManager.getUIElementsInfo( iToolType )
    For Each x in oFrame.LayoutManager.getElements()
        s = s & x.ResourceURL & CHR$(10)
        If x.ResourceURL = "private:resource/toolbar/custom_toolbar_50c37ac9" Then
        	' I'd like to display the items inside this toolbar...
        End If
    Next
    MsgBox s, 0, "Toolbars in Component"

Could you please tell me how I can get the items that are inside this toolbar ?
Once the items are listed, I will then be able to display or hide the items.

Thanks for your help.

Unfortunately it isn’t so easy to control the Toolbar, you can get some small info with the macro

Sub simpleInfoAboutToolbar
	dim oDoc,  oFrame
	dim oCfgManager
	dim oToolInfo
	dim x, y, z
	dim s$,  s2$
	dim iToolType as Integer, i&
	oDoc=ThisComponent
	rem This is the integer value three.
	iToolType=com.sun.star.ui.UIElementType.TOOLBAR
	oFrame=oDoc.getCurrentController().getFrame()
	oCfgManager=oDoc.getUIConfigurationManager()
	oToolInfo=oCfgManager.getUIElementsInfo(iToolType)
	for each x in oFrame.LayoutManager.getElements()
		's = s & x.ResourceURL & CHR$(10)
		if x.ResourceURL="private:resource/toolbar/textobjectbar" then ' "private:resource/toolbar/custom_toolbar_50c37ac9"
			y=x.RealInterFace.AccessibleContext
			for i=0 to y.AccessibleChildCount-1
				z=y.getAccessibleChild(i)
				s2=s2 & i & " " & z.AccessibleName & chr(10)
			next i
		end if
	next
	msgbox s2
	'    MsgBox s, 0, "Toolbars in Component"
End Sub

but complete control is more complicated