Results 1 to 3 of 3

Thread: Creating excell spread sheet

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2002
    Location
    Canada
    Posts
    455

    Post

    Hello dear VB programmers,

    Is there a possibility to create in VB5 an excell spreadsheet and maybe how to create sheets?

    nice regards,

    michelle.

  2. #2
    Hyperactive Member venkatraman_r's Avatar
    Join Date
    Jul 1999
    Location
    Chennai, INDIA
    Posts
    284

    Post

    Hi,

    All you need to do is use an OLE control....

    Venkat.

    ------------------
    [email protected]
    ICQ: 45714766
    http://venkat.iscool.net

  3. #3
    Hyperactive Member
    Join Date
    Jun 1999
    Posts
    308

    Post

    Hi,Michrlle.

    You have to set reference to Microsoft Excel Object Library and don't forget set object to Nothing when you are done with it.
    Here is a code:

    Dim AppExcel As Excel.Application
    Dim wSheet As Worksheet
    Dim wBook As Workbook

    Screen.MousePointer = vbHourglass

    If AppExcel.Workbooks.Count = 0 Then
    ' "Adding a new Workbook"
    Set wBook = AppExcel.Workbooks.Add
    End If
    Set wSheet = AppExcel.Sheets(1)
    wSheet.Cells(2, 1).Value = "1st quater"
    wSheet.Cells(2, 2).Value = "2nd quater"
    wSheet.Cells(3, 1) = 123
    wSheet.Cells(3, 2) = 435
    Range("A2:B2").Select
    With Selection.Font
    .Name = "Verdana"
    .FontStyle = "Bold"
    .Size = 12
    End With

    Range("A3:B3").Select
    With Selection.Font
    .Name = "Verdana"
    .FontStyle = "Regular"
    .Size = 11
    End With
    Range("A2:B2").Select
    Selection.Columns.AutoFit
    Selection.ColumnWidth = Selection.ColumnWidth * 1.25
    Range("A2:B2").Select
    Selection.HorizontalAlignment = xlCenter
    AppExcel.Visible = True

    Screen.MousePointer = vbDefault

    End Sub

    Larisa


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