DocumentBase.TransformDocument 方法

將指定的可延伸樣式表語言轉換 (XSLT) 檔套用至文件,並且使用結果取代文件。

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

語法

'宣告
Public Sub TransformDocument ( _
    path As String, _
    dataOnly As Boolean _
)
public void TransformDocument(
    string path,
    bool dataOnly
)

參數

  • dataOnly
    型別:System.Boolean
    true 表示只會將轉換套用至文件中的資料,Microsoft Office Word XML 則排除在外。false 表示將轉換套用至整份文件,包括 Word XML。預設值為 true。

備註

選擇性參數

如需選擇性參數的詳細資訊,請參閱Office 方案中的選擇性參數

範例

下列程式碼範例會使用指定的 XSLT 檔,只轉換文件中的資料。 此範例假設 CustomTransform.xslt 檔存在 C 根目錄中。 若要使用這個範例,請在文件層級專案中的 ThisDocument 類別執行。

Private Sub DocumentTransformDocument()
    Me.TransformDocument("C:\CustomTransform.xslt", True)
End Sub 
private void DocumentTransformDocument()
{
    this.TransformDocument(@"C:\CustomTransform.xslt", true);
}

.NET Framework 安全性

請參閱

參考

DocumentBase 類別

Microsoft.Office.Tools.Word 命名空間