OpenAsDocument Method Example

This example opens the template attached to the active document, displays a message box if the template contains anything more than a single paragraph mark, and then closes the template.

Set aDoc = ActiveDocument.AttachedTemplate.OpenAsDocument
If aDoc.Content.Text <> Chr(13) Then
    MsgBox "Template is not empty"
Else
    MsgBox "Template is empty"
End If
aDoc.Close SaveChanges:=wdDoNotSaveChanges

This example saves a copy of the Normal template as "Backup.dot."

Set aDoc = NormalTemplate.OpenAsDocument
With aDoc
    .SaveAs FileName:="Backup.dot"
    .Close SaveChanges:=wdDoNotSaveChanges
End With

This example changes the formatting of the Heading 1 style in the template attached to the active document. The UpdateStyles method updates the styles in the active document.

Set aDoc = ActiveDocument.AttachedTemplate.OpenAsDocument
With aDoc.Styles(wdStyleHeading1).Font
    .Name = "Arial"
    .Size = 16
    .Bold = False
End With
aDoc.Close SaveChanges:=wdSaveChanges
ActiveDocument.UpdateStyles