Results 1 to 4 of 4

Thread: Using Excel

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2000
    Posts
    2

    Exclamation

    Hello,

    Just a quick question. How can I use excel with my VB Application ? I have an excel file but I dont know how to incorporate it with my VB apps. I know how to do it with MS Access but with Excel I can't. May I ask for your suggestions and help on this one, quite need the info.

    Thanks in advance.

    Paul

  2. #2
    Frenzied Member
    Join Date
    Aug 1999
    Location
    Santa Clara, Ca , 95058
    Posts
    1,105
    You can add a reference to Micrsoft Excel #.# Object library and then open an instance of excel in your code:

    Global goXLApp As excel.Application
    Global goXLBooks as excel.workbook



    Set goXLApp = New excel.Application
    Set goXLBooks = goXLApp.Workbooks.Open(App.Path & "C:\data\filename.XLS")

    'read cell b1 (you'll see why in a minute)

    If Mid(CStr(goXLBooks.worksheets(1).Cells(1, 2).Value), 1, 5) = "Error" Then
    'note that the column letter gets changed to a number and that you access a cell by row, column
    gsMsgBoxMsg = "Unable to read Excel cell B,1. Contact support for help"
    form.Cell.Text = "0"
    Else
    form.cell.Text = Format(goXLBooks.worksheets(1).Cells(1, 2).Value, "###,###,###,###.00")
    End If

    [Edited by JHausmann on 08-29-2000 at 04:22 PM]

  3. #3

    Thread Starter
    New Member
    Join Date
    Aug 2000
    Posts
    2

    Smile

    Hi,

    Thank you very much for your reply. May I ask how would I configure the properties of... say... my textbox if I'm going to use the Excel file? Sorry, quite a beginner at this, as I know if using an Access database you would set the Data Source and Data Field properties of the textbox. Would this be also done?

    Thanks again.

  4. #4
    Frenzied Member
    Join Date
    Aug 1999
    Location
    Santa Clara, Ca , 95058
    Posts
    1,105
    Except for ADO, you cannot bind the data to a control. It's simple enough to do manually, my first post would place the data from a spreadsheet cell into a field. You simply need to invert it to send the data back to excel.

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