Bagikan melalui


How to: Create Office Projects in Visual Studio

You can use Visual Studio 2010 to create application-level add-ins and document-level customizations for Microsoft Office applications. For more information about these types of projects, see Office Solutions Development Overview.

Applies to: The information in this topic applies to document-level projects and application-level projects for Microsoft Office 2010 and the 2007 Microsoft Office system. For more information, see Features Available by Office Application and Project Type.

Note

Your computer might show different names or locations for some of the Visual Studio user interface elements in the following instructions. The Visual Studio edition that you have and the settings that you use determine these elements. For more information, see Visual Studio Settings.

To create an application-level add-in project

  1. On the File menu, point to New, and then click Project. If your IDE is set to use Visual Basic development settings, on the File menu, click New Project.

    The New Project dialog box appears.

  2. In the combo box at the top of the dialog box, select .NET Framework 3.5 or .NET Framework 4. For more information about choosing the target framework, see Designing and Creating Office Solutions.

    Note

    If you target the .NET Framework 4, the .NET Framework 4 Client Profile is targeted by default. For more information, see .NET Framework Client Profile.

  3. In the templates pane, under the node for the language you want to use, expand Office.

  4. Select the 2010 or 2007 node.

  5. In the list of project templates, select an add-in project template. For a list of available add-in project templates, see Office Project Templates Overview.

    Note

    If project templates are not visible when you select the 2010 or 2007 node, make sure that .NET Framework 3.5 or .NET Framework 4 is selected in the combo box at the top of the dialog box. Office projects in Visual Studio 2010 require one of these versions of the .NET Framework.

  6. In the Name box, type a name for the project. By default, the project name is also used as the solution name.

  7. In the Location box, enter the path where you want to create the project. You can use absolute and UNC paths. Do not use HTTP, FTP, or other protocol paths.

    Locations have the following formats:

    • [drive]:\

    • \\Server\Share

    Do not use these characters in the location:

    • Asterisk (*)

    • Vertical bar (|)

    • Colon (:) (except following the drive letter)

    • Double quotation mark (") (paths that contain spaces do not need quotation marks)

    • Less than (<)

    • Greater than (>)

    • Question mark (?)

    • Percent sign (%)

  8. Click OK.

    Note

    Add-in projects are always saved when they are created. They cannot be created as temporary projects. For more information about temporary projects, see Temporary Projects.

To create a document-level customization project

  1. On the File menu, point to New, and then click Project. If your IDE is set to use Visual Basic development settings, on the File menu, click New Project.

    The New Project dialog box appears.

  2. In the combo box at the top of the dialog box, select .NET Framework 3.5 or .NET Framework 4. For more information about choosing the target framework, see Designing and Creating Office Solutions.

    Note

    If you target the .NET Framework 4, the .NET Framework 4 Client Profile is targeted by default. For more information, see .NET Framework Client Profile.

  3. In the templates pane, under the node for the language you want to use, expand Office.

  4. Select the 2010 or 2007 node.

  5. In the list of project templates, select a document-level project template. For a list of available document-level project templates, see Office Project Templates Overview.

    Note

    If project templates are not visible when you select the 2010 or 2007 node, make sure that .NET Framework 3.5 or .NET Framework 4 is selected in the combo box at the top of the dialog box. Office projects in Visual Studio 2010 require one of these versions of the .NET Framework.

  6. In the Name box, type a name for the project. By default, this name is also used for the document. If your IDE is set to use Visual C# development settings or General development settings, also enter a location and solution name.

    Note

    You cannot use surrogate characters in the path of the project location or in the project name. For information about surrogate characters, see Unicode Support for Surrogate Pairs and Combining Character Sequences. Also, if you plan to deploy the solution for use offline, the characters in the project name must fit the HTTP protocol specifications.

  7. Click OK.

    The Visual Studio Tools for Office Project Wizard opens.

  8. Select Create a new document if you want to create a new document for the solution, or select Copy an existing document if you want to customize an existing document.

    If you create a new document, specify the name in the Name box and select the format of the document by using the Format box. For more information about the available formats, see Architecture of Document-Level Customizations.

    If you use an existing document, specify the location of the document in the Full path of the existing document box. You can use absolute and UNC paths. Do not use HTTP, FTP, or other protocol paths to the document.

    Locations have the following formats:

    • [drive]:\

    • \\Server\Share

    Do not use these characters in the location:

    • Asterisk (*)

    • Vertical bar (|)

    • Colon (:) (except following the drive letter)

    • Double quotation mark (") (paths that contain spaces do not need quotation marks)

    • Less than (<)

    • Greater than (>)

    • Question mark (?)

    • Percent sign (%)

    Note

    If you use an existing document in a Word 2010 project, only use documents created in Word 2010 or converted to Word 2010. Certain features will be disabled in the document if you use a document that was created in an earlier version of Word. If you try to write code that uses these features, you might encounter errors in your project. To convert a document, open it in Word 2010, click the File tab on the Ribbon, click Info, and then click Convert.

  9. Click Finish.

  10. Add the project folder and its subfolders to the list of trusted locations in the Trust Center in Word in the following cases:

    • You are creating a Word Document that is based on a .doc or .docm file, and the document contains a VBA project or hosts Windows Forms controls. Adding the project folder to the list of trusted locations will help make sure that the document works as expected at design time.

    • You are creating a Word Template project that is based on a .dot file. You must add the project folder to the list of trusted locations so that you can run and debug the project.

    For more information on how to add a document to the trusted locations, see the Microsoft Office Online Web site Create, remove, or change a trusted location for your files.

See Also

Tasks

How to: Build Office Solutions

Concepts

Collaborative Development of Office Solutions

Getting Started Programming Application-Level Add-Ins

Other Resources

Office Project Templates Overview

Designing and Creating Office Solutions