Hello, I am trying to read an excel 2007 file. All I want is the first box in the excel file to be dispayed in a label on my windows form. I found a tutorial on here, however, it is not working. Seems like an easy thing to do, any suggestions? I am using VB .Net 2008 and Excel 2007. I get an exception error on the line where I declare the file name of the excel file.
Code:Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim oXLApp As Excel.Application Dim oXLBook As Excel.Workbook Dim oXLSheet As Excel.Worksheet oXLBook = oXLApp.Workbooks.Open(Application.StartupPath & "Book1.xlsx") oXLApp.Visible = True oXLBook = Nothing oXLApp = Nothing Dim my_variable As String my_variable = oXLSheet.Cells(1, 1).Value Label1.Text = "Current: " & my_variable End Sub




Reply With Quote