Back to Devexpress

RichEditControl.LoadDocumentTemplate(String, DocumentFormat) Method

windowsforms-devexpress-dot-xtrarichedit-dot-richeditcontrol-dot-loaddocumenttemplate-x28-system-dot-string-devexpress-dot-xtrarichedit-dot-documentformat-x29.md

latest4.1 KB
Original Source

RichEditControl.LoadDocumentTemplate(String, DocumentFormat) Method

Loads a document template from the file in the specified format.

Namespace : DevExpress.XtraRichEdit

Assembly : DevExpress.XtraRichEdit.v25.2.dll

NuGet Package : DevExpress.Win.RichEdit

Declaration

csharp
public virtual bool LoadDocumentTemplate(
    string fileName,
    DocumentFormat documentFormat
)
vb
Public Overridable Function LoadDocumentTemplate(
    fileName As String,
    documentFormat As DocumentFormat
) As Boolean

Parameters

NameTypeDescription
fileNameString

A string specifying the file to load (including the full path).

| | documentFormat | DocumentFormat |

One of the DocumentFormat enumeration values indicating the document format.

|

Returns

TypeDescription
Boolean

true if the document is successfully loaded; otherwise, false.

|

Remarks

The document template cannot be automatically overwritten either in code or in the UI. The information about the original file location and its format is dropped. An attempt to save (i.e., overwrite) the original document invokes the Save As dialog that enables the end-user to specify a different file name and format.

The code sample below loads a document template from a file.

csharp
richEditControl.LoadDocumentTemplate("Documents\\Template.docx", DocumentFormat.Docx);
vb
richEditControl.LoadDocumentTemplate("Documents\\Template.docx", DocumentFormat.Docx)

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the LoadDocumentTemplate(String, DocumentFormat) method.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

winforms-richeditcontrol-common-api/CS/RichEditAPISample/CodeExamples/RichEditControlActions.cs#L261

csharp
RichEditControl richEdit = e.Item.Tag as RichEditControl;
    richEdit.LoadDocumentTemplate("Documents\\LoremDocumentTest.docx", DevExpress.XtraRichEdit.DocumentFormat.OpenXml);
}

winforms-richeditcontrol-common-api/VB/RichEditAPISample/CodeExamples/RichEditControlActions.vb#L268

vb
Dim richEdit As RichEditControl = TryCast(e.Item.Tag, RichEditControl)
    richEdit.LoadDocumentTemplate("Documents\LoremDocumentTest.docx", DevExpress.XtraRichEdit.DocumentFormat.OpenXml)
End Sub

See Also

Troubleshooting

RichEditControl Class

RichEditControl Members

DevExpress.XtraRichEdit Namespace