DocumentAttachedTemplate Property

Gets or sets the full path of the template attached to the document.

Namespace:  Aspose.Words
Assembly:  Aspose.Words (in Aspose.Words.dll) Version: 20.8.0


public string AttachedTemplate { get; set; }

Property Value

Type: String


ArgumentNullExceptionThrows if you attempt to set to a null value.


Empty string means the document is attached to the Normal template.


Shows how to set a default .docx document template.
Document doc = new Document();

// If we set this flag to true while not having a template attached to the document,
// there will be no effect because there is no template document to draw style changes from
doc.AutomaticallyUpdateStyles = true;
Assert.That(doc.AttachedTemplate, Is.Empty);

// We can set a default template document filename in a SaveOptions object to make it apply to
// all documents we save with it that have no AttachedTemplate value
SaveOptions options = SaveOptions.CreateSaveOptions("Document.DefaultTemplate.docx");
options.DefaultTemplate = MyDir + "Business brochure.dotx";

doc.Save(ArtifactsDir + "Document.DefaultTemplate.docx", options);

See Also