Saving macros and toolbars in Writer templates

I’m using the latest version of Writer ( 4.4.5.2). I create documents in .odt format based upon templates with custom styles. I want to use macros to apply direct formatting to change text color, which I do on a temporary basis while I review content. I want to create a custom toolbar with controls to add the formatting (fire the macro). I’ve managed to do this at the LibreOffice level, but never with a template, which is what I want to do, since I don’t need this stuff in all of the documents I work with.

My questions are these:

If I want the macros to apply to every .odt created using my template, can I record the macros in the template and have them available to new documents as well as existing documents based upon that template the next time I open them?

If I save macros anywhere, what is the difference between saving them in a library and a module?

Can I create a custom toolbar that appears only for documents based upon my template?

the primary difference I have seen is whether they travel with the document or instead must be installed to new machines separately in an oxt or by similar method.

Hi

In addition to doug’s response:

  1. You can record macros in a template and have them available to new documents as well as existing documents based upon that template the next time you open them.
  2. Principle is to save macros in a place accessible to the template… If macros are eg. in a library installed by extension, the advantage is that the user does not has to validate the execution of macros when opening the document. Reminder: this execution depends on Tools Options LibreOffice Security Macros security
  3. You can create a custom toolbar that appears only for documents based upon the template.

See MyToolBar.ott: select “foo” and click a button in the custom toolbar

Regards

I can see that you’ve done what I was trying to do.

What location would be accessible to the template? Where should I save my macros? I’ve created a library in the template (editing the .ott) and saved the macros there, but when I open a document based upon that template, the macros are not available in that file. The toolbars as well.

Just to be sure we understand each other: I wrote that macros and toolbars are available in documents created from the template. I wanted to say documents created from the template already including macros and toolbars. They are not available for documents created before the creation of macros.

A-HA! That’s the problem! :slight_smile: Many thanks.