Share via

VBA Attached templates

Anonymous
2017-10-23T21:50:12+00:00

I was wondering what is the difference between these two sets of code on word templates:

 AddIns.Add FileName:= _

'        "C:\Procedure Macros\Procedure Master 2010.dotm", Install:=True

'    With ActiveDocument

'        .UpdateStylesOnOpen = True

'        .AttachedTemplate = "C:\Procedure Macros\Procedure Master 2010.dotm"

'        '.XMLSchemaReferences.AutomaticValidation = True

'        '.XMLSchemaReferences.AllowSaveAsXMLWithoutValidation = False

'    End With

and this:

ActiveDocument.AttachedTemplate = "C:\Procedure Macros\Procedure Master 2010.dotm"

thanks,

Cindy

Microsoft 365 and Office | Word | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

Jay Freedman 207.7K Reputation points Volunteer Moderator
2017-10-24T03:36:18+00:00

The first example includes the second example, when the "With ActiveDocument" is combined with the ".AttachedTemplate = ..."  However, the first example includes a lot more.

Installing a template as an add-in and also making it the document's attached template is fairly unusual, because the macros, shortcuts, and user interface customizations that would be supplied by an add-in are also things that are available from the attached template. The attached template also supplies styles, which add-ins do not supply.

Setting the ActiveDocument.UpdateStylesOnOpen = True applies the template's style definitions to overwrite any differently defined styles of the same names in the document. Setting it to True and leaving it that way could be dangerous if some other template (such as the Normal.dotm) is attached later and contains different style definitions, as the updating could cause unwanted reformatting.

The .XMLSchemaReferences properties will prevent saving the document if it fails validation against an attached XML schema (this is rather uncommon).

Was this answer helpful?

3 people found this answer helpful.
0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Anonymous
    2017-10-25T15:30:49+00:00

    Thank you for explaining, it helps!

    Cindy

    Was this answer helpful?

    0 comments No comments