Excel file with Chart Sheet as first sheet - Exception

Hi @Thiago

Actually you are getting this error because your cast is wrong because you are using “Excel Activity Scope” with it.

Namespace: Microsoft.Office.Interop.Excel
Assembly: Microsoft.Office.Interop.Excel (in microsoft.office.interop.excel.dll)

This interface only gives you worksheets - not charts.

Go to Remark section :slight_smile:

On the other hand, if you will use “Workbook Activities” so it’s instance _Workbook.Sheets gives you a Sheets instance.

Go to Remark section :slight_smile:

The interfaces are not assignable to each other; therefore, you are getting the COM error.

i have not yet tried so do not know it’s possible to get an instance of the Worksheets interface through the “Office Primary Interop Assemblies”.

As long as you will use workbook activities i.e. _Workbook.Worksheets property instead of the _Workbook.Sheets property, you should get an instance of Sheets that only returns Worksheet objects for these charts objects etc. as i explained above.

ChartExcel.zip (15.0 KB)

Regards…!!
Aksh

7 Likes