简体   繁体   中英

opening excel in vb.net error

what do you think is wrong with the commented line in my vb.net code below? it returns the error message "member not found". thank you.

Public Function tae(ByVal SourcePath 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(SourcePath), Excel.Workbook)     //somethings wrong here
    oxlSheet = CType(oxlBook.Worksheets(1), Excel.Worksheet)

    oxlApp.Workbooks.Close()
    oxlApp.Quit()

End Function

i tried to add the following references and its now ok:

  • ms excel x object library
  • ms office x object library
  • visual basic for applications

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM