Udostępnij za pośrednictwem


ServerDocument Sample

Note

This sample runs only in Microsoft Office Excel 2007 and Microsoft Office Word 2007.

This sample tool provides a graphical user interface and a command-line interface that enable you to view and modify a Visual Studio Tools for Office document's _AssemblyLocation property as described in Custom Document Properties Overview. This tool also enables you to view and modify data that is cached in the document.

The application manifest contains information that is used at run time or design time to describe the solution that is associated with a document. The application manifest is accessible through the ServerDocument object, which provides an API for working with the application manifest. This sample tool uses that API to enable you to view and modify the application manifest and data cached in a Visual Studio Tools for Office solution document.

Security noteSecurity Note:

This sample code is intended to illustrate a concept, and it shows only the code that is relevant to that concept. It may not meet the security requirements for a specific environment, and it should not be used exactly as shown. We recommend that you add security and error-handling code to make your projects more secure and robust. Microsoft provides this sample code "AS IS" with no warranties.

To run this sample

  • Press F5.

To remove a customization from a document

  1. On the File menu, click Open, and then open a Visual Studio Tools for Office document-level customization that uses Microsoft Visual Studio Tools for the Microsoft Office system (version 3.0 Runtime).

  2. On the Edit menu, click Remove Customization.

To add a customization to a document

  1. On the File menu, click Open, and then open a document. The document does not have to be a Visual Studio Tools for Office solution document.

  2. On the Edit menu, click Add Customization.

  3. Enter the location of the deployment manifest URL and click OK.

To view cached data

  1. On the File menu, click Open, and then open a Visual Studio Tools for Office document-level customization that uses Microsoft Visual Studio Tools for the Microsoft Office system (version 3.0 Runtime).

  2. In the Cached Data panel, select an item in the tree view to display the data.

  3. You can make changes to the data and save the changes by clicking Save on the File menu.

To remove cached data

  1. On the File menu, click Open, and then open a Visual Studio Tools for Office solution document.

  2. On the Edit menu, click Remove Cached Data.

  3. On the File menu, click Save.

To use the command-line version

  1. Open the Command Prompt window.

  2. To view the options, type the following command.

    VSTOServerDocumentSample.exe /?
    

Demonstrates

  • How to work with ServerDocument and associated objects.

  • How to view and manage cached data.

  • How to attach and remove a customization.

  • How to delete cached data.

See Also

Concepts

Caching Data

Accessing Data in Documents on the Server

Application and Deployment Manifests in Office Solutions

Data in Document-Level Customizations

Other Resources

Document-Level Samples