Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

Excel Template Project Template

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

The Excel Template project template in Visual Basic and Visual C# provides the groundwork for applications that target new or existing Microsoft Office Excel 2003 templates. The template automatically adds the necessary project references, files, and basic code to use as a starting point for your application.

Some of the files and references listed below are hidden by default. To see them, click Show All Files on Solution Explorer.

There are some files and references not listed below that are common to many Visual Studio project templates.

If you open a template to edit it outside of Visual Studio after the solution has been compiled, the template will run the code just as if you had created a new document from the template. Depending on the code, this could alter the template while it opens, before you begin to edit. To prevent the code from running, hold down the SHIFT key while you open the template.

The following methods are included in the project template code file.

Startup (Sheet1_Startup, ThisWorkbook_Startup)

Startup is called after the workbook is running and all the initialization code in the assembly has been run. It is the last thing to run in the constructor of the class that your code is running in.

The Startup events in a workbook are raised in this order:

  1. ThisWorkbook.

  2. Sheet1.

  3. Sheet2.

  4. Sheet3.

  5. Other sheets in order.

The order is determined when the project is compiled. If the user rearranges the sheets at run time, it does not change the order that the events are raised the next time the workbook is opened.

Shutdown (Sheet1_Shutdown, ThisWorkbook_Shutdown)

Shutdown is called on each of the worksheets and the workbook when the application domain that your code is loaded in is about to unload. It is the last thing to be called in the class as it unloads.

These are the main user files. They are visible by default.

NoteNote

You cannot add additional classes to the code file behind a document, workbook, or worksheet. You must add new files to your project to contain any classes you want to write.

  • ExcelTemplate1.xls - Represents the Excel workbook in the project. Contains all of the worksheets and charts.

  • Sheet1 (.vb file for Visual Basic or .cs file for Visual C#) - A worksheet that provides the design surface and the code for the first worksheet in the workbook. For more information, see Worksheet.

  • Sheet2 (.vb file for Visual Basic or .cs file for Visual C#) - A worksheet that provides the design surface and the code for the second worksheet in the workbook.

  • Sheet3 (.vb file for Visual Basic or .cs file for Visual C#) - A worksheet that provides the design surface and the code for the third worksheet in the workbook.

  • ThisWorkbook (.vb file for Visual Basic or .cs file for Visual C#) - Contains the design surface and the code for workbook-level customizations. For more information, see Workbook.

Hidden Files

Microsoft Visual Studio 2005 Tools for the Microsoft Office System generates these hidden files. Do not modify these files manually; they are regenerated when changes are made to the project and they do not retain manual modifications.

  • .Designer.xml - A read-only declarative representation of the programmable objects in the worksheet or workbook.

  • .Designer (.vb file for Visual Basic or .cs file for Visual C#) - A read-only code file that provides helper implementations, including code to instantiate objects correctly.

  • <Document Name>.Designer.xml - A read-only declarative representation of programmable objects such as custom controls that are not a part of Visual Studio Tools for Office by default.

  • <Document Name>.Designer (.vb file for Visual Basic or .cs file for Visual C#) - A read-only code file that provides helper implementations for custom controls.

  • Microsoft.Office.Core - The primary interop assembly for shared Office components.

  • Microsoft.Office.Tools.Common - A collection of helper implementations for developing actions pane and smart tags solutions.

  • Microsoft.Office.Interop.Excel - The primary interop assembly for Excel.

  • Microsoft.Office.Tools.Excel - Implementations of Excel controls and managed controls.

  • Microsoft.VisualStudio.Tools.Applications.Runtime - The component that loads the main project assembly in Excel.

  • Microsoft .NET Framework assemblies - A collection of references to some of the Microsoft .NET Framework assemblies that are used when developing Visual Studio Tools for Office solutions.

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft