ServerDocument..::.RemoveCustomization Method (2007 System)
This page is specific to:.NET Framework Version:3.54.0
Visual Studio Tools for Office API Reference
ServerDocument..::.RemoveCustomization Method (2007 System)

Removes the Visual Studio Tools for Office customization from the document.

Namespace:  Microsoft.VisualStudio.Tools.Applications
Assembly:  Microsoft.VisualStudio.Tools.Applications.ServerDocument.v9.0 (in Microsoft.VisualStudio.Tools.Applications.ServerDocument.v9.0.dll)
Syntax

'Usage

Dim documentPath As String

ServerDocument.RemoveCustomization(documentPath)

'Declaration

Public Shared Sub RemoveCustomization ( _
    documentPath As String _
)

Parameters

documentPath
Type: System..::.String
The full path of the document from which you want to remove the customization.
Exceptions

ExceptionCondition
ArgumentNullException

The documentPath parameter is nullNothingnullptra null reference (Nothing in Visual Basic) or empty or consists completely of white space characters.

FileNotFoundException

The file specified by documentPath does not exist.

IOException

The file specified by documentPath is read-only, or cannot be accessed.

InvalidOperationException

The file specified by documentPath does not have a Visual Studio Tools for Office customization, or an error occurred while loading the manifest.

DocumentCustomizedWithPreviousRuntimeException

The file specified by documentPath has a customization that was created by using an earlier version of the Visual Studio Tools for Office runtime.

Remarks

This method clears the deployment manifest URL and the cached data manifest, and removes any cached data from the document. For more information, see How to: Remove Managed Code Extensions from Documents (2007 System).

Examples

The following code example uses the RemoveCustomization method to remove the customization from the specified document. The example first calls the GetCustomizationVersion method to determine whether the document has a Visual Studio Tools for Office customization.

This example requires a reference to the Microsoft.VisualStudio.Tools.Applications.ServerDocument.v9.0.dll and Microsoft.VisualStudio.Tools.Applications.Runtime.v9.0.dll assemblies, and Imports (for Visual Basic) or using (for C#) statements for Microsoft.VisualStudio.Tools.Applications and Microsoft.VisualStudio.Tools.Applications.Runtime namespaces at the top of your code file.

Private Shared Sub RemoveAssembly(ByVal documentPath As String)
    Dim runtimeVersion As Integer = 0

    Try
        ' Make sure that this customization was created using the correct runtime.
        runtimeVersion = ServerDocument.GetCustomizationVersion(documentPath)
        If runtimeVersion <> 3 Then
            MessageBox.Show("This document does not have a Visual Studio Tools for Office " & _
                "customization, or it has a customization that was created with a version of " & _
                "the runtime that is incompatible with this version of the ServerDocument class.")
            Return
        End If

        ServerDocument.RemoveCustomization(documentPath)
        MessageBox.Show("The customization has been removed.")

    Catch ex As System.IO.FileNotFoundException
        System.Windows.Forms.MessageBox.Show("The specified document does not exist.")
    Catch ex As System.IO.IOException
        System.Windows.Forms.MessageBox.Show("The specified document is read-only.")
    Catch ex As UnknownCustomizationFileException
        System.Windows.Forms.MessageBox.Show("The specified document has a file " & _
            "extension that is not supported by Visual Studio Tools for Office.")
    Catch ex As InvalidOperationException
        System.Windows.Forms.MessageBox.Show("The customization could not be removed." & _
            vbLf & ex.Message)
    End Try
End Sub


Permissions

See Also

Reference

Other Resources

© 2009 Microsoft Corporation. All rights reserved.   Terms of Use | Trademarks | Privacy Statement
Page view tracker
Rate the Lightweight library
x
Lightweight builds on ScriptFree (loband) by adding features you've requested: a SearchBox and default code language selection.
Do you like the SearchBox?
Do you like the tabbed code blocks?
How useful is this topic?
Tell us more.
Thanks
x
You're helping to improve MSDN Online.
Feedback
Switch View
Classic
Lightweight Beta
ScriptFree
Switch View