Modfied toolbar not showing in existing documents (SOLVED)

I have a customised toolbar that shows on all new documents based on a template. Existing documents based on that same (albeit older version) template do not display the toolbar even though the newer template is attached (via “Change Template Macro”) to the document. All Styles update correctly and, so far, my only solution is to c&p the entire document to a new one and saving it over the original. Surely there is an easier way to import customised toolbars into a document. Suggestions, please.

EDIT: I have had a thought that these toolbars must be stored somewhere, but where? And, how do I copy them into the appropriate place?

You can save the modified toolbar elements in the application or in the document.
In the first case the modified toolbar elements will be appeared in all of the documents (new ones and existing ones) but it will be happened on that PC only where you created them.
In the secontd case the modified toolbar elemets will be appeared in the document/template only where you created them, and in the documents created based on the template.
I suppose that the template changer extension can import only the formatting properties (PageStyles, ParagraphStyles, CharacterStyles, etc), but not the macros and not the modified toolbar elements from the source template. Check it in the source code of the “Change Template Macro”.

1 Like

Do you mean the template-changer extension?

User defined Toolbars are saved in User Profile in directory config. Backup your user profile and you can experiment :slight_smile:.

1 Like

Could not find them there. They seem to be stored in the template file (if I open it with file manager I can find them there.)

As an aside, do you know of a method to create a new, blank, document via code. I’ve been searching all day and the nearest I get is “New does not exist” this code
OF COURSE New doesn’t exist, I want to create it!

Sub NewFile
    Dim Doc As Object
    Dim sPath as String
    Dim sDocURL as String
	Dim Dummy()
    sDocURL = ThisComponent.URL()	
    sPath = DirectoryNameoutofPath(sDocURL,"/")
    sPath = sPath+"/New.odt"
    Doc = StarDesktop.loadComponentFromURL(sPath, "_Blank", 0, Dummy)	
End Sub

doc = StarDesktop.loadComponentFromURL( "private:factory/swriter", "_blank", 0, Dummy)
1 Like

ODT file is renamed ZIP, you can rename the ODT (OTT, ODS, ODG etc.) to ZIP, unpack it, and then I think you will see also the directory config and XML file there (if you changed Toolbar in document). But I’m not sure if it is sufficient only to copy XML from document config ot config in User Profile,or it is neccessary also edit some next XML in User Profile.

I’ve worked out how to copy the appropriate files from the “zip” file,however, it would be easier to create a new document based upon the correct template and copy the data to there. (And save it as the correct [new] filename). This is currently what I am working on, as per my reply above

I’m not sure if the easy way for changing toolbar in document exists.
Here are 2 examples, I think I downloaded it from somewhere OOo forum before some years.
change-text-of-toolbar-button.odt (10.7 kB)
add-toolbar-with-images-buttons.odt (21.0 kB)

And here is example how to work with inner XML files without “unzipping” document.

I’ve worked out how to create a new doc with C&P to it then saving it as the recent document name. So now I shall file this as SOLVED. Currently I’m working my way through all the code I have tried (and failed) and streamlining the working code. Thank you all for your assistance, I cannot really flag one reply as the solution, but you all have guided my process, so THANK YOU ALL!