本文為機器翻譯文章。如需檢視英文版,請選取 [原文] 核取方塊。您也可以將滑鼠指標移到文字上,即可在快顯視窗顯示英文原文。
譯文
原文

DocumentBase.CustomXMLParts 屬性

 

傳回文件中的自訂 XML 組件。

命名空間:   Microsoft.Office.Tools.Word
組件:  Microsoft.Office.Tools.Word.v4.0.Utilities (於 Microsoft.Office.Tools.Word.v4.0.Utilities.dll)

public CustomXMLParts CustomXMLParts { get; }

屬性值

Type: Microsoft.Office.Core.CustomXMLParts

Microsoft.Office.Core.CustomXMLParts 集合,包含文件中的自訂 XML 組件。

For more information about using custom XML parts in Office projects, see Custom XML Parts Overview.

The following code example embeds employee data in the document by adding a Microsoft.Office.Core.CustomXMLPart to the P:Microsoft.Office.Tools.Word.DocumentBase.CustomXMLParts collection in the current document. To use this example, run it from the ThisDocument class in a document-level project.

private void AddCustomXmlPartToDocument()
{
    string xmlString =
        "<?xml version=\"1.0\" encoding=\"utf-8\" ?>" +
        "<employees xmlns=\"http://schemas.microsoft.com/vsto/samples\">" +
            "<employee>" +
                "<name>Karina Leal</name>" +
                "<hireDate>1999-04-01</hireDate>" +
                "<title>Manager</title>" +
            "</employee>" +
        "</employees>";

    Office.CustomXMLPart employeeXMLPart = this.CustomXMLParts.Add(xmlString, missing);
}
回到頁首
顯示: