Condividi tramite


Office Project Templates Overview

The Microsoft Office developer tools in Visual Studio include project templates for creating the following types of Office solutions:

  • Document-level customizations

  • Application-level add-ins

For a detailed comparison of these types of Office solutions, see Office Solutions Development Overview.

The Office project templates are available in the New Project dialog box, under the Office node of the Visual C# and Visual Basic language nodes. Each template generates a project with the appropriate configuration for the target application, including assembly references and debugging settings.

Each project provides files and code to get you started on a specific kind of solution. The generated code for each project includes startup and shutdown event handlers. You can add code to these event handlers to initialize your solution when it is loaded and to clean up your solution when it is unloaded. For more information, see Office Projects in the Visual Studio Environment and Events in Office Projects.

Note

The Office development tools are included with certain editions of Visual Studio. For more information, see Configuring a Computer to Develop Office Solutions.

Document-Level Customizations

The Office node in the New Project dialog box provides the following project templates to get you started creating document-level customizations for Word and Excel:

  • Word 2013 Document

  • Word 2013 Template

  • Excel 2013 Workbook

  • Excel 2013 Template

  • Word 2010 Document

  • Word 2010 Template

  • Excel 2010 Workbook

  • Excel 2010 Template

The Word Document and Excel Workbook project templates provide code to get you started creating a solution that is based on a specific document or workbook. In these types of solutions, your code runs only when the associated document is open in Word or Excel.

The Word Template and Excel Template project templates behave identically to the Word Document and Excel Workbook project templates. However, the Word Template and Excel Template project templates makes it easy for users to create new local document or workbook copies of the customized template in your solution. The features in your solution are available from the new document that the user creates from the template.

Note

Word templates that reference managed code extensions cannot be used as global add-ins. The assembly is not called if the template is loaded from the Startup directory of Word. For more information, see Limitations of Global Templates and Excel Add-ins (.xla Files)

For information about getting started with these project types, see the following topics:

Application-Level Add-ins

The Office/SharePoint node in the New Project dialog box provides the following project templates to get you started creating application-level add-ins.

  • Excel 2013 Add-in

  • InfoPath 2013 Add-in

  • Outlook 2013 Add-in

  • PowerPoint 2013 Add-in

  • Project 2013 Add-in

  • Visio 2013 Add-in

  • Word 2013 Add-in

  • Excel 2010 Add-in

  • InfoPath 2010 Add-in

  • Outlook 2010 Add-in

  • PowerPoint 2010 Add-in

  • Project 2010 Add-in

  • Visio 2010 Add-in

  • Word 2010 Add-in

When you create a project that is based on one of these project templates, the code in your solution runs when the associated application is open. Unlike document-level projects, your code is not associated with a single document.

For more information about getting started with these project types, see the following topics:

Document vs. Template Solutions

When you design a solution around a Word document or Excel workbook, you must decide the best way to make that document available to your users.

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

In some situations, you might want to give a copy of a document to each user. In this case, create your solution by using an Excel or Word document project.

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. In this case, create your solution by using an Excel or Word template project.

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.

Limitations of Global Templates and Excel Add-ins (.xla Files)

Documents, workbooks, and templates might not work correctly as global templates or Excel add-ins (.xla files).

Word Templates

If a Microsoft Office Word template has managed code extensions, the project assembly is not called if the template is attached as a global template or loaded from the startup directory of Word. In addition, the document does not recognize the format of a template that is part of an Office solution.

Excel Add-Ins (.xla Files)

There is no Office project for creating an Excel add-in (.xla file). It is possible to save a workbook as an .xla file, but it is not a supported operation and is not recommended. If you save a workbook that has managed code extensions as a Microsoft Office Excel Add-In (*.xla) file, you can select it in the Add-Ins dialog box to apply to another workbook. In some cases your code will run in the target workbook after the add-in is applied, but such use of the Office solution is not supported.

See Also

Tasks

How to: Create Office Projects in Visual Studio

Concepts

Getting Started Programming Document-Level Customizations for Excel

Getting Started Programming Document-Level Customizations for Word

Getting Started Programming Application-Level Add-Ins

Other Resources

Designing and Creating Office Solutions

Developing Office Solutions