How to remove custom toolbar?

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
grnhorn
Posts: 32
Joined: Sun Jul 13, 2008 2:07 pm

How to remove custom toolbar?

Post by grnhorn »

I am looking for a macro to remove a custom toolbar created by macro for BasicIDE. Every time I try it, it removes the bar, but I can't put it back without completely closing and reopening OO.

Thanks...
OOo 2.4.X on Ms Windows XP
User avatar
foxcole
Volunteer
Posts: 1507
Joined: Mon Oct 08, 2007 1:31 am
Location: Minneapolis, Minnesota

Re: How to remove custom toolbar?

Post by foxcole »

grnhorn wrote:I am looking for a macro to remove a custom toolbar created by macro for BasicIDE. Every time I try it, it removes the bar, but I can't put it back without completely closing and reopening OO.
Hello, grnhorn.

Please help me understand your question... What do you mean by "every time I try it"---what are you trying, exactly? And if you're trying to remove the bar, why do you want to put it back? I'm confused.
Cheers!
---Fox

OOo 3.2.0 Portable, Windows 7 Home Premium 64-bit
grnhorn
Posts: 32
Joined: Sun Jul 13, 2008 2:07 pm

Re: How to remove custom toolbar?

Post by grnhorn »

The following code will allow the installation of a toolbar for basicIDE, but if the toolbar is removed by code, it cannot be reinstalled. The reinstallation puts residue on the toolbar. Please run to see. Line use to remove tool bar is just above 'End Sub'.

Code: Select all

Sub Main
	REM *** Creates a new custom toolbar persistently for the Basic IDE
	
	REM *** The name of our new custom toolbar. A custom toolbar name MUST
	REM *** start with "custom_"!
	sToolbar = "private:resource/toolbar/custom_toolbar"
	
	REM *** Retrieve the module configuration manager from central module configuration manager supplier 
	oModuleCfgMgrSupplier = createUnoService("com.sun.star.ui.ModuleUIConfigurationManagerSupplier")
	
	REM *** Retrieve the module configuration manager with the module identifier
	REM *** See com.sun.star.frame.ModuleManager for more information
	oModuleCfgMgr = oModuleCfgMgrSupplier.getUIConfigurationManager( "com.sun.star.script.BasicIDE" )
	
	REM *** Create a settings container which will define the structure of our new
	
	REM *** custom toolbar.
	oToolbarSettings = oModuleCfgMgr.createSettings()
	
	REM *** Set a title for our new custom toolbar
	oToolbarSettings.UIName = "My little custom toolbar"
	
	REM *** Create a button for our new custom toolbar
	sString = "My Macro's"
REM This line of code does not work...
	oToolbarItem = CreateToolbarItem( "macro:///Standard.Module1.Test()", "Standard.Module1.Test" )
	oToolbarSettings.insertByIndex( nCount, oToolbarItem )
	
	REM *** Set the settings for our new custom toolbar. (replace/insert)
	if ( oModuleCfgMgr.hasSettings( sToolbar )) then
		oModuleCfgMgr.replaceSettings( sToolbar, oToolbarSettings )
	else
		oModuleCfgMgr.insertSettings( sToolbar, oToolbarSettings )
	endif

REM Line to remove toolbar:
'       oModuleCfgMgr.insertSettings( sToolbar, oToolbarSettings )

End Sub
OOo 2.4.X on Ms Windows XP
Post Reply