Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2003
    Posts
    4

    Unanswered: import specific excel data to access

    Hi, i am trying to import specific cells from an excel spreadsheet corresponding text boxes in an access form. Could someone please help me here? thanx

  2. #2
    Join Date
    Sep 2003
    Location
    T.O.
    Posts
    326
    You need to create an excel workbook object and point it to your file, define your sheet and then your range, then grab your data:

    Dim xlWB As Excel.Workbook

    Dim xlSheet As Excel.Worksheet

    Set xlWB = Excel.Workbooks.Open("YourPathGoesHere")

    Set xlSheet = xlWB.Worksheets("YourSheetGoesHere")

    MsgBox xlSheet.Cells(2, 1) ' or xlSheet.Range("A2")

    Set xlSheet = Nothing
    xlWB.Close
    Set xlWB = Nothing

    Instead of MsgBox, you can assign the value to something else.
    All code ADO/ADOX unless otherwise specified.
    Mike.

  3. #3
    Join Date
    Oct 2003
    Posts
    4

    Talking

    thanx mate! that worked nicely!









    Originally posted by HomerBoo
    You need to create an excel workbook object and point it to your file, define your sheet and then your range, then grab your data:

    Dim xlWB As Excel.Workbook

    Dim xlSheet As Excel.Worksheet

    Set xlWB = Excel.Workbooks.Open("YourPathGoesHere")

    Set xlSheet = xlWB.Worksheets("YourSheetGoesHere")

    MsgBox xlSheet.Cells(2, 1) ' or xlSheet.Range("A2")

    Set xlSheet = Nothing
    xlWB.Close
    Set xlWB = Nothing

    Instead of MsgBox, you can assign the value to something else.

Posting Permissions

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