tags:

views:

208

answers:

2

i have a function in VB.net 2002 (see code below) and i get a "MEMBER NOT FOUND" error. cant figure out whats wrong..

Public Function GetSheetName_control(ByVal Filename As String) As String
    Dim oxlApp As Excel.Application
    Dim oxlBook As Excel.Workbook
    Dim oxlSheet As Excel.Worksheet

    oxlApp = CType(CreateObject("Excel.Application"), Excel.Application)
    oxlBook = CType(oxlApp.Workbooks.Open(Filename), Excel.Workbook)  /*ERROR IN THIS LINE*/
    oxlSheet = CType(oxlBook.Worksheets(1), Excel.Worksheet)
    oxlApp.Workbooks.Close()
    oxlApp.Quit()

    /*more codes below...*/
End Function
A: 

I am not sure why that should occur.

Looking at your code, I have 1 question.

Why are you instantiating the oxlApp using CreateObject (which is a late bound way of instantiation) when you have declared oxlApp as Excel.Application?

Why not use oxlApp = new Excel.Application?

shahkalpesh
hmm.. i'll check it now
sef
it doesnt work either
sef
shahkalpesh
A: 

Member not found exceptions usualy get solved by cleaning and rebuilding the application.

chrissie1