I have a functional program that reads a few cells from and Excel worksheet but with option strict I get an error that "Option Strict On disallows late binding." In the past I disabled option strict as a workaround but today I wanted to do it right. Imports Microsoft.Office.Interop.
Why does removing the CType generate the error? Isn't Worksheets.items() of the type Excel.Worksheet?
Interestingly I read this perfect article on the MSDN so I created a new sub and pasted it in. It too ends up with the error. And it's supposed to demonstrate how to use early binding to avoid this error. What am I doing wrong?
vb.net Code:
Dim excel As Excel.Application Dim ewb As Excel.Workbook = excel.Workbooks.Open("A:\myfile.xlsx") Dim ews As Excel.Worksheet = CType(ewb.Worksheets.Item("Main"), Excel.Worksheet)
Interestingly I read this perfect article on the MSDN so I created a new sub and pasted it in. It too ends up with the error. And it's supposed to demonstrate how to use early binding to avoid this error. What am I doing wrong?