Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Applying an XSLT Transform [Word 2003 XML Reference]

Applying an XSLT Transform [Word 2003 XML Reference] --  Microsoft Office Word 2003 XML Software Development Kit

Office 2003

Applying an XSLT Transform [Word 2003 XML Reference]

Microsoft© Office Word 2003 allows the application of Extensible Stylesheet Language Transformation (XSLT) files to XML while several different ways. You do it either manually or automatically while opening a document or saving a document. You can also apply an XSLT while the document is open using Microsoft Visual Basic© for Applications (VBA). A complete description of each method follows.

Applying an XSL Transformation while saving a document

Caution  If you apply an Extensible Stylesheet Language Transformation (XSLT) when you save an Extensible Markup Language (XML) file, Word saves only data that is included in the output of the transformation.

Manually applying an XSL Transformation while saving a document

Automatically applying an XSL Transformation while saving a document

Applying an XSL Transformation to while opening a document

When you add an XML schema to the Schema Library, you can associate one or more Extensible Stylesheet Language Transformation (XSLT) files with the schema. When you attach that schema to a document and open the document in Microsoft Word, you can specify how to display the data by selecting one of the available data views, or XSLTs, to apply to the incoming XML data.

Manually applying an XSL Transformation while opening a document

Automatically applying an XSL Transformation while opening a document

Applying an XSL Transformation on an open document with VBA

Note  The following steps assume that you are familiar with VBA and using the Office Word 2003 object model.

You can use VBA to apply a transform to the active document with a small amount of code.

  1. On the Tools menu, point to Macro, and then click Visual Basic Editor. You can also use the shortcut Alt+F11.
  2. From the View menu, choose Immediate Window.
  3. In the Immediate Window type:

    ActiveDocument.TransformDocument(

  4. After the open parenthesis, enter values for TransformDocument's two parameters:
    • Path As String is the full path to the location of applied XSLT.
    • DataOnly As Boolean is false you want the transform to affect all of the document's WordprocessingML and true if you want it to only affect the custom XML. This parameter parallel's the Save data only check box in the Save As dialog when saving a document as XML. This parameter defaults to True.
  5. Add the final closing parenthesis and hit Enter to apply the transform specified by the Path parameter.

More Information

For more information on the option settings used to configure the XML features in Word, see Understanding XML Options. For suggestions on troubleshooting problems that may occur while using these features, see Troubleshooting XML Documents in Word.

For additional information and examples that describe or demonstrate the end-to-end process of working with XML documents in Word, see the following articles:

Editing XML Data with Microsoft Office Word 2003 and Microsoft Office Excel 2003
Creating and Applying an XML Resume Template in Microsoft Office Word 2003
Microsoft Office Word 2003 XML: Memo Styles Sample
XML and Microsoft Office Word 2003: Writing a Trip Report


©2004 Microsoft Corporation. All rights reserved. Permission to copy, display and distribute this document is available at: http://msdn.microsoft.com/library/en-us/odcXMLRef/html/odcXMLRefLegalNotice.asp
Show:
© 2015 Microsoft