Results 1 to 10 of 10

Thread: [RESOLVED] [2008] Retrieve value from excel file

Threaded View

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2008
    Posts
    7

    Resolved [RESOLVED] [2008] Retrieve value from excel file

    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
    Last edited by Roxbury22; Sep 24th, 2008 at 05:46 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width