CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 1999
    Posts
    5

    How VB can create a table in Excel worksheet.



    I have encountered a problem the writing codes to create the tables in excel worksheet. Therefor I hope to get some suggestions and recommendation to solve my problem. Thanks a lots for your helps.


    Vivien Lee



  2. #2
    Join Date
    May 1999
    Posts
    15

    Re: How VB can create a table in Excel worksheet.





    here is the part of code:

    ------------------------------------------------

    Private Sub Command1_Click()


    Dim x1 As Object

    Dim sheet As Object

    Set x1 = CreateObject("Excel.Application")

    x1.Workbooks.Add

    Set sheet = x1.ActiveWorkbook.Sheets(1)

    x1.Visible = True

    For i = 0 To 2

    For j = 0 To 9

    sheet.Cells(i + 1, j + 1).Value = i + j

    Next j

    Next i

    sheet.SaveAs "c:\temp\data.xls"

    x1.Quit

    Set x1 = Nothing

    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

Featured