Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

Certain Microsoft Office Excel 2003 properties do not appear in the Object Browser or in Microsoft IntelliSense when you automate Excel by using C#


View products that this article applies to.

Summary

When you automate Microsoft Office Excel 2003 by using the C# programming language, certain Excel properties do not appear in the Object Browser or in Microsoft IntelliSense as you may expect. For example, the Range property of the Worksheet object and the Value property of the Range object do not appear in the Object Browser or in IntelliSense.

↑ Back to the top


More information

The C# programming language does not expect non-default properties to have parameters. However, some properties in the Excel object model do have parameters. Therefore, C# may access properties in the Excel object model that have parameters as methods. These properties may appear in the Object Browser and in IntelliSense prefixed with get_, or prefixed with set_, or prefixed with both get_ and set_.

The following C# code sample uses Excel properties that have the get_Range method and the set_Value method:
//Start Excel, and then add a new workbook.
Excel.Application oXl = new Excel.Application();
Excel.Workbooks oBooks = oXl.Workbooks;
Excel.Workbook oBook = 
	oBooks.Add(System.Reflection.Missing.Value);
Excel.Sheets oSheets = oBook.Sheets;

//Acquire a reference to the first worksheet in the new workbook.
Excel.Worksheet oSheet = (Excel.Worksheet)oSheets["Sheet1"];

//Acquire a reference to cell A1 on the worksheet, and then set the
//value for the range.
Excel.Range oRange = oSheet.get_Range("A1","A1");
oRange.set_Value(Excel.XlRangeValueDataType.xlRangeValueDefault,
	"Hello World!");

//Make Excel visible, and then give the user control.
oXl.Visible = true;
oXl.UserControl = true;

↑ Back to the top


Keywords: KB824004, kbpia, kbprb, kbautomation

↑ Back to the top

Article Info
Article ID : 824004
Revision : 3
Created on : 2/3/2006
Published on : 2/3/2006
Exists online : False
Views : 416