Create a new Excel file from your program, fill the
Excel file cells
with values, and save it.
The user will not see the Excel environment at all!
Private Sub Command1_Click()
Dim xlApp As Excel.Application
Dim
xlWB As Excel.Workbook
Dim xlWS As Excel.Worksheet
Set xlApp = New Excel.Application
Set xlWB = xlApp.Workbooks.Add
Set xlWS =
xlWB.Worksheets.Add
' This following lines will fill the cell
(2,2) with the text "hello",
' and will fill the cell (1,3) with
the text "World"
xlWS.Cells(2, 2).Value =
"hello"
xlWS.Cells(1, 3).Value = "World"
' The following line saves the spreadsheet to
"c:\mysheet.xls" file.
xlWS.SaveAS
"c:\mysheet.xls"
xlApp.Quit
' Free memory
Set xlWS =
Nothing
Set xlWB = Nothing
Set xlApp
= Nothing
End Sub