Managing Documents on a Server by Using the ServerDocument Class

You can use the ServerDocument class in the Visual Studio Tools for Office runtime to manage several aspects of document-level customizations, even if Microsoft Office Word and Microsoft Office Excel are not installed. You can perform the following tasks:

  • Access and modify data in the data cache of a document or workbook. For more information, see Working With Cached Data in the Document.

  • Manage the customization assembly that is associated with a document. For more information, see Managing the Document Customization.

Applies to: The information in this topic applies to document-level projects for the following applications: Excel 2007 and Excel 2010; Word 2007 and Word 2010. For more information, see Features Available by Office Application and Project Type.

Understanding the ServerDocument Class

The ServerDocument class is designed to be used on computers that do not have Office installed. Therefore, you typically use this class in applications that do not integrate with Office, such as Console projects or Windows Forms projects, rather than Office projects.

There are two different versions of the ServerDocument class in the Visual Studio 2010 Tools for Office Runtime. The version you should use depends on the target .NET Framework of the application in which you want to use the class:

  • For applications that target the .NET Framework 4, use the Microsoft.VisualStudio.Tools.Applications.ServerDocument class in the Microsoft.VisualStudio.Tools.Applications.ServerDocument.dll assembly. 

  • For applications that target the .NET Framework 3.5, use the Microsoft.VisualStudio.Tools.Applications.ServerDocument class in the Microsoft.VisualStudio.Tools.Applications.ServerDocument.v10.0.dll assembly.

Both versions of the ServerDocument class can be used to operate on document-level customizations that were created by using Visual Studio 2010, or on document-level customizations for Excel 2007 and Word 2007 that were created by using Visual Studio 2008.

For more information about the Visual Studio 2010 Tools for Office Runtime and the Office extensions for the .NET Framework, see Visual Studio Tools for Office Runtime Overview.

Note

If you have a legacy application that uses the ServerDocument class in the Visual Studio Tools for Office system (version 3.0 Runtime), the Visual Studio Tools for Office system (version 3.0 Runtime) must be installed on computers that run the application. The Visual Studio 2010 Tools for Office Runtime cannot run these applications.

Working With Cached Data in the Document

The ServerDocument class provides members you can use to work with the data cache in customized documents. For more information about cached data, see Caching Data and Accessing Data in Documents on the Server.

The following table lists the members you can use to work with cached data.

Task

Member to use

To determine whether a document has a data cache.

The IsCacheEnabled method.

To access the cached data in a document.

For more information, see Accessing Data in Documents on the Server.

The CachedData property.

Managing the Document Customization

You can use members of the ServerDocument class to manage the customization assembly that is associated with a document. For example, you can programmatically remove the customization from a document so that the document is no longer part of a customization.

The following table lists the members you can use to manage the customization assembly.

Task

Member to use

To determine whether a document is part of a document-level customization.

The GetCustomizationVersion method.

To programmatically attach a customization to a document at run time.

For more information, see How to: Attach Managed Code Extensions to Documents

One of the AddCustomization methods.

To programmatically remove a customization from a document at run time.

For more information, see How to: Remove Managed Code Extensions from Documents.

The RemoveCustomization method.

To get the URL of the deployment manifest that is associated with the document.

The DeploymentManifestUrl property.

See Also

Tasks

How to: Attach Managed Code Extensions to Documents

How to: Remove Managed Code Extensions from Documents

Reference

Microsoft.VisualStudio.Tools.Applications.ServerDocument

Concepts

Visual Studio Tools for Office Runtime Overview

Caching Data