Get OLEObject.Object with Csharp

B

Bragadiru

Hi,

I want to change the Value and BackColor of all OLEObjects from my xls files
(more than 1000 files), BUT how can I cast to a specific type
(Excel.OLEObject.Object is object ype in Csharp) ??

:
using Excel = Microsoft.Office.Interop.Excel;

Excel.Application excelApp = new Excel.Application();

Excel.Workbook wrkBook = excelApp.Workbooks.Open(file, Type.Missing,
Type.Missing, Type.Missing, ... , Type.Missing) ;

Excel.Worksheet wrkSheet = (Excel.Worksheet)wrkBook.Worksheets[1];

Excel.OLEObjects oleObjects =
(Excel.OLEObjects)wrkSheet.OLEObjects(Type.Missing);

foreach(Excel.OLEObject oleObject in oleObjects)
{
oleObject.Enabled = true;
//oleObject.Object is type object. How can I access Value property ?
}

Thanks for any advice
 
Joined
Jan 16, 2008
Messages
1
Reaction score
0
I have a similar problem. I want to change the MultiSelect Property of a ListBox using a C# code

OLEObject oleobject = oleobjects.Add("Forms.ListBox.1", Missing.Value, false, false, Missing.Value, Missing.Value, Missing.Value, TargetCell.Left, TargetCell.Top, TargetCell.Width, TargetCell.Height);

It creates a new Listbox

Now I want to change its Multiselect property. In VBA it would be oleobject.Object.MultiSelect = 2 (e.g)

But HOW IN .NET???????????

oleobject.Object.?????????

Thank you!!!
 
Last edited:

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top