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.

Getting Started Writing Code

Document-level customizations that you create by using Visual Studio Tools for Office are based around documents. In these solutions, there is a code file associated with each Microsoft Office Word 2003 document, and with each Microsoft Office Excel 2003 workbook and worksheet. The model is the same as Windows Forms and Web Forms; there is a design view for working with the user interface, and there is a code view where you write your code.

Application-level add-ins that you create by using Visual Studio Tools for Office are based around an instance of a Microsoft Office application. In these solutions, there is a code file that is associated with an add-in for a Microsoft Office application. Add-in projects provide a code view where you write your code; there is no design view.

NoteNote

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

Opening the Code View

You can get to the code view in multiple ways:

  • Click the View Code button on the Solution Explorer toolbar. The insertion point appears at the top of the window.

  • Click the View Code menu item on the Visual Studio View menu when either a document or corresponding code project item is selected in Solution Explorer. The insertion point appears at the top of the window.

  • Click the View Code item on the document's context menu. The insertion point appears at the top of the window.

  • Click the View Code item on the context menu of a control, including host controls. The insertion point appears at the top of the window. For more information about view controls, see Host Items and Host Controls Overview.

  • Click View Code on the project item context menu in Solution Explorer. The insertion point appears at the top of the window.

  • Double-click a control in the visual designer. The insertion point appears inside the default control event handler. The event handler is generated if it does not exist already.

Office Code Examples

There are examples of Microsoft Office automation code throughout the Visual Studio Tools for Office documentation. The following topics are good starting points.

For examples of this See this topic

Automating Excel.

Excel Tasks

Automating Word.

Word Tasks

Automating Outlook.

Outlook Tasks

Using control events.

Controls in Microsoft Office Projects

Creating Microsoft Office toolbars and menus.

Office UI Customization Overview

Working with actions panes.

Actions Pane Overview

Creating custom task panes.

Custom Task Panes Overview

Creating Outlook form regions.

Outlook Form Regions Overview

Customizing the Ribbon user interface.

Ribbon Extensibility Overview

Using Windows Forms in your solution.

Walkthrough: Collecting Data Using a Windows Form

Pulling data from a data source into your document.

Connecting to Data

Microsoft Office solution samples you can open and run.

Office Development Samples

Adding Office Descriptions to IntelliSense

Visual Studio IntelliSense does not include descriptions of objects and parameters for many Microsoft Office objects. Typically, text that describes an object or parameter appears in the Quick Info and Parameter Info features, along with the syntax. However, for many objects in the Microsoft Office object model, this text is not available by default.

You can install files that provide these descriptions for some Microsoft Office applications. Visual Studio Tools for Office provides these files for download from the Web. For more information, see the download Web page at http://go.microsoft.com/fwlink/?LinkId=50425.

See Also

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

Show:
© 2014 Microsoft