Share via


RemoveCustomization 方法 (2003 系統)

從文件中移除 Microsoft Visual Studio Tools for the Microsoft Office system (3.0 版) 自訂。

命名空間:  Microsoft.VisualStudio.Tools.Applications.Runtime
組件:  Microsoft.VisualStudio.Tools.Applications.Runtime (在 Microsoft.VisualStudio.Tools.Applications.Runtime.dll 中)

語法

'宣告
Public Shared Sub RemoveCustomization ( _
    documentPath As String _
)
'用途
Dim documentPath As String

ServerDocument.RemoveCustomization(documentPath)
public static void RemoveCustomization(
    string documentPath
)

參數

例外狀況

例外狀況 條件
ArgumentNullException

documentPath 參數為 null Nothing nullptr Null 參照 (即 Visual Basic 中的 Nothing) ,或空字串,或整個都是空白字元。

FileNotFoundException

documentPath 所指定的檔案不存在。

IOException

documentPath 所指定的檔案為唯讀或無法存取。

InvalidOperationException

documentPath 所指定的檔案不含 Visual Studio Tools for Office 自訂,或載入資訊清單時發生錯誤。

備註

這個方法會清除應用程式資訊清單和快取的資料資訊清單,並移除文件的快取資料。如需詳細資訊,請參閱 HOW TO:從文件移除 Managed 程式碼擴充 (2003 系統)

範例

下列程式碼範例會使用 RemoveCustomization 方法,從指定的文件中移除自訂值。範例首先會呼叫 IsCustomized 方法,判斷文件是否含有 Visual Studio Tools for Office 自訂。這個範例需要對 Microsoft.VisualStudio.Tools.Applications.Runtime 組件的參考,並且在程式碼檔的開頭需要 Microsoft.VisualStudio.Tools.Applications.Runtime 命名空間的 Imports (適用於 Visual Basic) 或 using (適用於 C#) 陳述式。

Private Shared Sub Remove(ByVal fileName As String)
    If ServerDocument.IsCustomized(fileName) Then
        ServerDocument.RemoveCustomization(fileName)
        MsgBox("The customization has been removed.")
    Else
        MsgBox("The specified document is not " + _
            "customized.")
    End If
End Sub
private static void Remove(string fileName)
{
    if (ServerDocument.IsCustomized(fileName))
    {
        ServerDocument.RemoveCustomization(fileName);
        MessageBox.Show("The customization has been removed.");
    }
    else
    {
        MessageBox.Show("The specified document is not " +
            "customized.");
    }
}

使用權限

請參閱

參考

ServerDocument 類別

ServerDocument 成員

Microsoft.VisualStudio.Tools.Applications.Runtime 命名空間