How do I apply a new Calc template to an old Calc file

I followed the instructions for creating a new template and setting it as the Default Template. How do I apply that new template to an older Calc file?

Essentially, I want all my old styles to update to the newer format.

It is probably possible to write a macro that will copy styles of the same name from one Calc document to another. For Writer documents, this is described in this answer by @ajlittoz .

It looks like you have no other option than to create a new document with your new template, paste the contents of an existing document and reset formatting as necessary.

This proceeding may be advantageous in some cases, but it will not preserve the document properties including
creator, creation date, editing time, revision number, user defined properties
I did not understand the

There is an extension called Template Changer, but I never tested/used it.

A claim in the description of the mentioned extension is “A document template once set cannot be changed afterwards.”, but this is only correct as far as it is restricted to UI means.

If you need such an operation only rarely, and don’t want to install an extension, a few lines of Basic code can also do it.
You need to know name and exact folder-path of the template. Adapt the contained string constants in the code to your needs. (They are working as given below on my Win10 system with the exception of the user name for spreadsheet files.)

Sub chgTemplate(Optional pNTFolderP As String, Optional pNTNamed As String)
Const defaultNextTemplateFolderPath   = _
Const defaultNextTemplateName         ="MonoCalc.ots"
docProps = ThisComponent.DocumentProperties
If IsMissing(pNTFolderP) Then pNTFolderP = defaultNextTemplateFolderPath
If IsMissing(pNTNamed)       Then pNTNamed = defaultNextTemplateName
nextTemplatePathName                  = pNTFolderP & pNTNamed
nextTemplateURL                       = ConvertToURL(nextTemplatePathName)
docProps.TemplateName                 = pNTNamed
docProps.TemplateURL                  = nextTemplateURL
End Sub

The settings in the styles from the template will replace the styles in the document when it is opened next time if the template has a more recent date-time of the last save operation.

(Of course, any contents and internal formats that aren’t defined by styles only can go to documents newly created from the template.)

1 Like

Users visiting this thread may also be interested in the extension “Style Switcher”.
Since I never used it myself, this can’t be a recommendation! It’s simply a hint.
Also see the comments by @gabix below! (Thanks for the research!)

TemplateChanger seems to work for text documents only. In Calc, even respective menu entries do not show up.

StyleSwitcher is clearly for text documents as per its description:

This extension requires three document templates to be located in the template folder of your LibreOffice user profile:

  • (optimized for screen display)
  • (standard manuscript format)
  • (optimized for print output)