Template inheritance in Microsoft Word

J

Johan Nordberg

Is it possible for a Word template to inherit/refernce another
template? I'm about to create several templates with different content,
but the same code och forms and would like to store all code and forms
in one template and let other localized templates inherit from a base
template.

BaseTemplate.dot
---- Template_En.dot
-------- English document.doc
---- Template_Se.dot
-------- Swedish document.doc
 
S

Shauna Kelly

Hi Johan

Word templates don't inherit from one another.

For your purposes what you could do is to create two templates, each with
the content and styles you need. You'll need to set up your styles in each
template. As far as possible, use Word's built-in styles, even if you give
them an additional abbreviated name for each language.

Create a separate .dot file that holds all your code and forms. Then you
only have one lot of code to maintain. Load that as an add-in. If you want
it to load whenever a user starts Word, put it in the user's Word Startup
folder.

Alternatively, and perhaps more likely, you could have code in the template
that loads and unloads the add-in as required. The add-in can contain the UI
(toolbars etc) and all the code.

The following might also help:
What is the relationship between a Word document and its template?
http://www.ShaunaKelly.com/word/templaterelations\index.html

What happens when I attach a new template to my document? or How do I copy
content and settings from a template to a document?"
http://www.ShaunaKelly.com/word/attachtemplate/index.html

Post back if you need more information.

Hope this helps.

Shauna Kelly. Microsoft MVP.
http://www.shaunakelly.com/word
 
J

Johan Nordberg

Thank you Shauna! I actually found your articles after a bit of
Googleing.

What is the best way to programmaticly load and unload Word addins?

Regards // Johan
 
S

Shauna Kelly

Hi Johan

Try something like this, with appropriate error checking around it:

Sub LoadMyAddIn()

Dim oAddIn As Word.AddIn
Dim sMyPathAndFileName As String

sMyPathAndFileName = "C:\MyPath\MyAddIn.dot"

On Error Resume Next

'Try to get the add-in
Set oAddIn = Word.Application.AddIns(sMyPathAndFileName)

'If that didn't work, add it to the Add-ins collection and install it
If oAddIn Is Nothing Then
Set oAddIn =
Word.Application.AddIns.Add(FileName:=sMyPathAndFileName, Install:=True)
End If

'And make sure it's installed
If Not oAddIn.Installed Then
oAddIn.Installed = True
End If

If oAddIn Is Nothing Then
MsgBox "Error!"
End If

End Sub


Hope this helps.

Shauna Kelly. Microsoft MVP.
http://www.shaunakelly.com/word
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top