Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

How to: Remove Managed Code Extensions from Documents (2003 System)

Applies to

The information in this topic applies only to the specified Visual Studio Tools for Office projects and versions of Microsoft Office.

Project type

  • Document-level projects

Microsoft Office version

  • Microsoft Office 2003

For more information, see Features Available by Application and Project Type.

You can programmatically remove the Visual Studio Tools for Office customization assembly from a document or workbook that is part of a document-level customization for Microsoft Office 2003. Users can then open the documents and view the contents, but any custom user interface (UI) you add to the documents will not appear, and your code will not run. When you remove the assembly, you can choose to leave the cached data in the document or remove it:

  • If you want to keep the cached data, clear the application manifest that is embedded in the document. You might want to keep the cached data if it will be read later by an ASP.NET page or server application.

  • If you no longer need the cached data, clear both the application manifest and the cached data.

The Visual Studio Tools for Office runtime includes an object model that enables you to programmatically perform these actions.

Use the ServerDocument class to clear only the embedded application manifest. You must put code that uses the ServerDocument class in a new project (not your Visual Studio Tools for Office solution), for example in a console application or Windows Forms project.

To clear the embedded application manifest

  1. Create a new project, for example a console application or Windows Forms project.

  2. Add a reference to the Microsoft.VisualStudio.Tools.Applications.Runtime.dll assembly to the project.

  3. Add the following Imports or using statement to the top of your code file.

    using Microsoft.VisualStudio.Tools.Applications.Runtime;
    
  4. Create an instance of ServerDocument, and pass in the solution document. Call the Clear method of the AppManifest property.

    ServerDocument sd = null;
    try 
    {
        sd = new ServerDocument(@"C:\Documents\SolutionDocument.doc");
        sd.AppManifest.Clear();
    
  5. Save your changes and close the document.

        sd.Save();
    }
    finally
    {
        if (sd != null)
        {
            sd.Close();
        }
    }
    

You can clear both the embedded application manifest and cached data from the document by using one of the RemoveCustomization methods:

NoteNote:

The Document.RemoveCustomization and Workbook.RemoveCustomization methods also remove the Runtime Storage Control from the document. For more information about the Runtime Storage Control, see Runtime Storage Control Overview.

To clear the embedded application manifest and cached data from an open document on a client computer

To clear the embedded application manifest and cached data from a closed document or a document on a server

  1. Create a new project, for example a console application or Windows Forms project.

  2. Add a reference to the Microsoft.VisualStudio.Tools.Applications.Runtime.dll assembly to the project.

  3. Add the following Imports or using statement to the top of your code file.

    using Microsoft.VisualStudio.Tools.Applications.Runtime;
    
  4. Call the static RemoveCustomization(String) method of the ServerDocument class, and specify the solution document path for the parameter.

    if (ServerDocument.IsCustomized(@"C:\Documents\SolutionDocument.doc"))
    {
        ServerDocument.RemoveCustomization(@"C:\Documents\SolutionDocument.doc");
    }
    
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.