Results 1 to 2 of 2

Thread: Output in an excel spreadsheet?

Hybrid View

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 2001
    Location
    Brussels, Belgium
    Posts
    1

    Output in an excel spreadsheet?

    I'd like to be able to output the content of the labels in my vb program to specific cells in an excel spreadsheet. Can I do so? How?

    Thanks

  2. #2
    Frenzied Member jjortiz's Avatar
    Join Date
    Mar 2001
    Location
    NYC
    Posts
    1,768
    Make sure that you refrence the MS Excel object library
    Here is the code assuming that you have 4 labels
    Code:
    Private Sub Form_Load()
          Dim oXL As Excel.Application
          Dim oWB As Excel.Workbook
          Dim oSheet As Excel.Worksheet
          Dim oRng As Excel.Range
          
    
          'On Error GoTo Err_Handler
          
       ' Start Excel and get Application object.
          Set oXL = CreateObject("Excel.Application")
          oXL.Visible = True
          
       ' Get a new workbook.
          Set oWB = oXL.Workbooks.Add
          Set oSheet = oWB.ActiveSheet
          
       ' Add table headers going cell by cell.
          oSheet.Cells(1, 1).Value = Label1
          oSheet.Cells(1, 2).Value = Label2
          oSheet.Cells(1, 3).Value = Label3
          oSheet.Cells(1, 4).Value = Label4
          
          
    End Sub

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