Introduction to Word s XML Features


Introduction to Word's XML Features

The first thing to note about the XML features described in this chapter is that most of them are available only in Microsoft Office Professional Edition 2003 and the stand-alone version of Microsoft Office Word 2003. If you work with other Office Editionssuch as Microsoft Office Standard Edition 2003, Microsoft Office Student and Teacher Edition 2003, or Microsoft Office Basic Edition 2003the XML features described in this chapter are not available.

Many of the XML features of Word are accessed via Word's XML Structure task pane. To show the XML Structure task pane, if it is not already displayed, choose Task Pane in Word's View menu. The task pane has a drop-down list from which the XML Structure task pane can be selected, as shown in Figure 22.1.

Figure 22.1. Selecting the XML Structure task pane from the task pane's drop-down list.


The XML Structure task pane prompts you to go to the Templates and Add-Ins dialog box to attach an XML schema to the document. To get to the Templates and Add-Ins dialog box, you can click the Templates and Add-Ins hyperlink shown in the task pane in Figure 22.2, or choose Templates and Add-Ins from the Tools menu and then click the XML Schema tab.

Figure 22.2. The XML Structure task pane prompts you to go to the Templates and Add-Ins dialog box to add an XML schema.


Figure 22.3 shows the Templates and Add-Ins dialog box. This dialog box shows available XML schemas that can be attached to the Word document by checking the check box next to an available schema. It also provides a button to add a new schema to the document.

Figure 22.3. The Templates and Add-Ins dialog box with the XML Schema tab selected.


To add a new schema to the document, click the Add Schema button. When you click the Add Schema button, you are prompted to browse to the schema file you want to add to the document. Let's use the book-order schema we created in Chapter 21, "Working with XML in Excel." After you select the schema, the Schema Settings dialog box appears, as shown in Figure 22.4. Let's enter BookOrder as an alias or friendly name for the book-order schema.

Figure 22.4. Picking an alias for a newly added schema in the Schema Settings dialog box.


Click OK to dismiss the Schema Settings dialog box. Doing so returns you to the Templates and Add-Ins dialog box. The book-order schema has been added, as shown in Figure 22.5, and is attached to the current document, as shown by the checked check box next to the BookOrder schema. The BookOrder schema can be detached from the document by unchecking the check box.

Figure 22.5. The BookOrder schema has been attached to the Word document.


Now that the BookOrder schema has been added, it will be available for attachment to other documents because Word automatically adds any added schemas to Word's schema library. To manage Word's schema library, click the Schema Library button in the Templates and Add-Ins dialog box. The Schema Library dialog box appears, as shown in Figure 22.6. This dialog box provides the same Add Schema button that lets you add new schemas. It also can edit the Schema Settings dialog box for an already-added schema. You can select a schema and click the Schema Settings button to assign the book-order schema a different friendly name, for example. A Delete Schema button lets you delete a schema from the schema library.

Figure 22.6. The Schema Library dialog box.


The bottom half of the Schema Library dialog box provides options to associate Smart Document solutions with a document to which a particular schema is attached. In this book, we do not cover this part of Word's functionality, because VSTO provides an easier way to build Word solutions through the ActionsPane mechanism described in Chapter 15, "Working with the Actions Pane." We do cover the ability to use the Solutions section to associate an XSLT file with a particular schema, however.

When you close the Schema Library dialog box and the Templates and Add-Ins dialog box, the XML Structure pane is updated to show elements from the book-order schema, as shown in Figure 22.7. With the book-order schema attached to the document, you are ready to start applying XML elements to the document.

Figure 22.7. The XML Structure dialog box with the book-order schema attached to the document.





Visual Studio Tools for Office(c) Using Visual Basic 2005 with Excel, Word, Outlook, and InfoPath
Visual Studio Tools for Office: Using Visual Basic 2005 with Excel, Word, Outlook, and InfoPath
ISBN: 0321411757
EAN: 2147483647
Year: N/A
Pages: 221

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net