Partager via


Properties in Office projects

Applies to: yesVisual Studio noVisual Studio for Mac

Note

This article applies to Visual Studio 2017. If you're looking for the latest Visual Studio documentation, see Visual Studio documentation. We recommend upgrading to the latest version of Visual Studio. Download it here

There are several important properties that are available to Office projects in Visual Studio. These properties can be accessed in the Properties window.

Applies to: The information in this topic applies to document-level projects and VSTO Add-in projects. See Features available by Office application and project type.

Namespace for host item

Use the Namespace for Host Item property to change the namespace for host item classes (for example, the ThisAddIn, ThisWorkbook, or ThisDocument classes) in Visual C# projects. This property appears in the Properties window when you select the document node in a document-level project (such as ExcelWorkbook1.xlsx or WordDocument1.docx) or the application node in a VSTO Add-in project (such as Excel or Word) in Solution Explorer.

When you create a Visual C# Office project, host items are given a namespace based on the name of the project. It is recommended that you use the Namespace for Host Item property to change the namespace rather than edit the code files directly. When you use this property, the namespace is changed in the generated (hidden) code files, as well as in the visible code files.

CacheInDocument

The CacheInDocument property appears in the Properties window for document-level projects when you select an instance of a DataSet in the Visual Studio designer. Only public members can be cached; ensure that the Modifiers property is set to Public if you want to cache a DataSet.

This property takes a Boolean value:

Value2

The Value2 property is only available for Excel workbook or template projects. It appears under the Databindings property node in the Properties window when you select a NamedRange control on the worksheet designer.

Use the Value2 property in the Properties window to bind the Value2 property of the NamedRange to a field in your data source.

See also