Results 1 to 4 of 4

Thread: [RESOLVED] VB and Excel

  1. #1

    Thread Starter
    Lively Member
    Join Date
    May 2005
    Posts
    88

    Resolved [RESOLVED] VB and Excel

    Hi all again, I would like to make a small program so that I learn while doing it.

    I would like to input a lot of number and information in an excel sheet, and than I would like to access the data (read) from the excel sheet from VB and use it for sums.

    In other words, the excel sheet is to be filled manually. VB has to read it only. nothing should show onscreen apart from the form of the VB.

    I don't have the slightest idea of what to declare, how to communicate and how to read data from a specific cell.

    thanks all
    You should LEARN not COPY... by learning you could be original in future work ... by copying you will risk getting in trouble.

    And as always.... What goes around .. Comes Around.

  2. #2
    Hyperactive Member The_Duck's Avatar
    Join Date
    May 2005
    Location
    Leamington, UK
    Posts
    351

    Re: VB and Excel

    Take a look at Office Automation

  3. #3

    Thread Starter
    Lively Member
    Join Date
    May 2005
    Posts
    88

    Re: VB and Excel

    no luck... anyone else please?

    thanks btw
    You should LEARN not COPY... by learning you could be original in future work ... by copying you will risk getting in trouble.

    And as always.... What goes around .. Comes Around.

  4. #4

    Thread Starter
    Lively Member
    Join Date
    May 2005
    Posts
    88

    Re: VB and Excel

    Hello all. I have resolved this by the following code!

    VB Code:
    1. Dim xlapp As Excel.Application
    2. Dim xlbook As Excel.Workbook
    3. Dim obooks As Excel.Workbooks
    4. Dim xlsheet As Excel.Worksheet
    5.  
    6. xlapp = New Excel.Application
    7. obooks = xlapp.Application.Workbooks
    8. xlbook = obooks.Open(Application.StartupPath & "\test.xls")
    9. xlapp.Visible = True 'You can remove this line if you do not want to show the excel sheet
    10.  
    11. xlsheet = xlbook.ActiveSheet
    12.  
    13. MessageBox.Show(xlsheet.Cells(1, 1).value) 'were [B]1,1[/B] is [B]x,y[/B] in the excel sheet

    thanks all

    PS. You have to add a referance

    you can see it in the picture attached
    Attached Images Attached Images  
    Last edited by Xenobius; Jul 9th, 2005 at 11:29 AM. Reason: Forgot to tell you that you have to add a referance
    You should LEARN not COPY... by learning you could be original in future work ... by copying you will risk getting in trouble.

    And as always.... What goes around .. Comes Around.

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