表达式的类型为“对象",不是集合类型. [英] Expression is of type 'Object', which is not a collection type.

查看:83
本文介绍了表达式的类型为“对象",不是集合类型.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我正在做一些与excel oleobjects相关的任务.下面是vb.net代码,用于访问excel并验证ole对象.构建dll时,我收到一条错误消息
表达式的类型是对象",不是集合类型." 在行对于ExcelSheet.OLEObjects中的每个Excelobj".下面提到的代码段.

Hi,

I am doing some excel oleobjects related tasks. The below is the vb.net code to access the excel and verifying the ole object. while building the dll, I received an error message
"Expression is of type ''Object'', which is not a collection type." in the row "For Each Excelobj In ExcelSheet.OLEObjects". Please find out the code snippet mentioned below.

Private Excelobj As Microsoft.Office.Interop.Excel.OLEObjects
Private ExcelApp As Microsoft.Office.Interop.Excel.Application
Private ExcelWorkBook As Microsoft.Office.Interop.Excel.Workbook
Private ExcelSheet As Microsoft.Office.Interop.Excel.Worksheet

ExcelApp = New Microsoft.Office.Interop.Excel.Application

ExcelWorkBook = ExcelApp.Workbooks.Open(sNitroReport)
ExcelSheet = CType(ExcelWorkBook.Sheets.Item("Sheet1").Microsoft.Office.Interop.Excel.Worksheet)
ExcelApp.Visible = True
ExcelSheet.Activate()

For Each ExcelSheet In ExcelWorkBook.Worksheets
 For Each Excelobj In ExcelSheet.OLEObjects
    <code.......>
 next
next
</code.......>


请帮助我解决此问题.真的,我正在努力解决这个问题.

谢谢,
Sivakumar.M.


Please help me to resolve this issue. Really, I am struggling a lot to fix this out.

Thanks,
Sivakumar.M.

推荐答案

好吧,例外是告诉您确切的错误-ExcelSheet.OLEObjects不是集合.如果您进入代码并将鼠标悬停在OLEObjects上,它将告诉您类型是什么.也许您需要使用另一个属性来执行您想做的事情.
Well, the exception is telling you exactly what''s wrong - ExcelSheet.OLEObjects is not a collection. If you go into the code and hover the mouse over OLEObjects, it will tell you what the type is. Perhaps you need to use another property to do what you''re trying to do.


这篇关于表达式的类型为“对象",不是集合类型.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆