Click to See Complete Forum and Search --> : Creating excell spread sheet
michelle
Jan 10th, 2000, 06:57 PM
Hello dear VB programmers,
Is there a possibility to create in VB5 an excell spreadsheet and maybe how to create sheets?
nice regards,
michelle.
venkatraman_r
Jan 10th, 2000, 07:32 PM
Hi,
All you need to do is use an OLE control....
Venkat.
------------------
venkatraman_r@hotmail.com
ICQ: 45714766
http://venkat.iscool.net
LG
Jan 10th, 2000, 08:26 PM
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
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.