Results 1 to 2 of 2

Thread: reading from excel workbook

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2000
    Location
    Malaysia
    Posts
    7

    Question

    hi...

    i'm i need of urgent help here.

    i have one excel workbook. i want to get information from there and insert in into table in my database. can anyone tell me, how do i read the data using vb?

    i did some research on this and tried out one of my own, but it's not working. please help. thanks in advance.



    Jade

  2. #2
    Lively Member
    Join Date
    Sep 1999
    Location
    Liverpool, UK
    Posts
    64
    You'll need to make a reference (menu option 'Project\References') to Microsoft 9.0 Excel Object Library, and then use code along the lines of..

    Code:
    Dim ExApp As Excel.Application
    
    Set ExApp = New Excel.Application
    
    ' make Excel visible
    ExApp.Visible = True
    ' open the specified worksheet
    ExApp.Workbooks.Open "c:\my documents\whatever.xls"
    ' select Sheet 1
    ExApp.Sheets("Sheet 1").Select
    ' get the text from different cells
    MsgBox "Text in cell A1 is "+Range("A1").text
    MsgBox "Text in cell B2 is "+Range("B2").text
    MsgBox "Text in cell C5 is "+Range("C5").text
    ' close the workbook
    ExApp.Workbooks.Close
    ' close Excel
    ExApp.Quit
    Try recording some macros in Excel, that'll help you generate some more code.

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