ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Get OLEObject with CSharp (https://www.excelbanter.com/excel-programming/315544-get-oleobject-csharp.html)

Bragadiru

Get OLEObject with CSharp
 
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) ??

:
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,

Type.Missing, Type.Missing, Type.Missing, Type.Missing,

Type.Missing, Type.Missing, 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; ?????

}


Thanks for any advice




All times are GMT +1. The time now is 10:32 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com