This documentation is archived and is not being maintained.

Document vs. Template Files

Note Required applications

The features in this topic are available only if you have the required applications installed.

For more information, see Features Available by Product Combination.

  • One of these development environments:

    VSTO 2005

    -or-

    Visual Studio Team System

  • Microsoft Office 2003

When you design a solution around a Microsoft Office Word 2003 document or Microsoft Office Excel 2003 workbook using managed code extensions, you must decide the best way to make that document available to your users. In some situations, you might want to give a copy of a document to each user. In other situations you might want to make a template available on a server, so that each user can open the template and save a local copy as a document.

Comparison

The following table outlines the differences between documents and templates.

Documents Templates

Users can open and modify a document, unless it is set to be read-only. Any saved changes are kept in the original.

Users can open a template to create a local copy as a new document. They cannot modify the original unless they are given special permissions.

When opened, the document raises the Open event.

When opened, the template raises the New event.

You can take advantage of the New event that is raised by templates by using methods such as the following:

Word

// Add this method to your class.
private void ThisDocument_New()
{
    // Your code goes here.
}

// Add the New event handler to the InternalStartup method.
this.New += new Microsoft.Office.Interop.Word.DocumentEvents2_NewEventHandler(ThisDocument_New);

Excel

// Add this method to your class.
private void ThisWorkbook_New()
{
    // Your code goes here.
}

// Add the New event handler to the Startup method.
this.New += new Microsoft.Office.Tools.Excel.WorkbookEvents_NewEventHandler(ThisWorkbook_New);

See Also

Show: