Microsoft Word Technology Sample

[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]

This sample demonstrates using Microsoft Word from a managed application written in C#. Microsoft Word is the document component of Microsoft Office. Its object model is exposed through .NET Programmability Support. In the sample application, Microsoft Word is used as a COM server to demonstrate the interoperability of Microsoft Office with managed code.

Note Note

This sample requires Microsoft Office 2003 with .NET Programmability Support and Microsoft Office Primary Interop Assemblies.

For information about using the samples, see the following topics:

To install .NET Programmability Support for Microsoft Office

  1. Open the Control Panel and select Add or Remove Programs.

  2. Select Microsoft Office 2003 or Microsoft Word 2003, and click Change. In the dialog, ensure the Add or Remove Features option button is selected, and click Next.

  3. Select the Choose Advanced Customization of Applications checkbox, and click Next.

  4. Expand the node for Word and click the downward-facing arrow adjacent to .NET Programmability Support. Select Run from My Computer.

  5. Click Update.

To install the Microsoft Office Primary Interop Assemblies

A PIA contains type definitions for a native COM object. Once installed, specifying a type library when building an interop application is unnecessary.

To build the sample using the Command Prompt

  1. Open a Command Prompt window and navigate to the \CS subdirectory under the Word directory.

  2. Type msbuild WordAppCS.sln at the command line.

To build the sample using Visual Studio

  1. Open Windows Explorer and navigate to the \CS directory under the Word directory.

  2. Double-click the icon for WordAppCS.sln to open the file in Visual Studio.

  3. In the Build menu, select Build Solution.

The application will be built in the default \Bin\Debug directory.

To run the sample

  1. In the Command Prompt window, navigate to the directory that contains the built executable.

  2. Type WordApp.exe at the command line.

    Note Note

    This sample builds a console application. You must launch it using the command prompt in order to view its output. At the end of execution the sample will close the Internet Explorer window that it opened to show document methods and properties related to hyperlinks.

Microsoft Office 2003

Primary Interop Assemblies for Microsoft Office

.NET Framework Version: 2.0, 1.1, 1.0

The sample builds a console application written in C#. Review comments in the source code for more information about Office interoperability.