Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
Expand Minimize

DocumentBase.TransformDocument Method

Applies the specified Extensible Stylesheet Language Transformation (XSLT) file to the document and replaces the document with the results.

Namespace:  Microsoft.Office.Tools.Word
Assembly:  Microsoft.Office.Tools.Word.v4.0.Utilities (in Microsoft.Office.Tools.Word.v4.0.Utilities.dll)

public void TransformDocument(
	string path,
	bool dataOnly


Type: System.String

The path of the XSLT file.

Type: System.Boolean

true applies the transformation only to the data in the document, excluding Microsoft Office Word XML. false applies the transform to the entire document, including Word XML. Default value is true.

Optional Parameters

For information on optional parameters, see Optional Parameters in Office Solutions.

The following code example transforms only the data in the document using the specified XSLT file. This example assumes that the CustomTransform.xslt file exists at the root of the C directory. To use this example, run it from the ThisDocument class in a document-level project.

private void DocumentTransformDocument()
    this.TransformDocument(@"C:\CustomTransform.xslt", true);

© 2015 Microsoft