Consider this piece of code(vb6)
Dim bWasntRunning As Boolean 'Excel already running
Dim Excel As Object 'Excel-object
Private Sub Yourbutton_Click()
Dim ExcelSheet As Object
' ---------------------------------------------------
'Start Excel if not running.
' ---------------------------------------------------
bWasntRunning = False
'Try first to use an existing instance.
Set Excel = GetObject(, "Excel.Application"

If Err Then
Err.Clear
'Excel isn't running, so start it.
bWasntRunning = True
Set Excel = CreateObject("Excel.Application"

If Err <> 0 Then
MsgBox CL("Could Not Load Excel!"

, vbExclamation
End
End If
End If
On Error GoTo 0
' ---------------------------------------------------
'Section 3. Get Excel ready to receive the data.
' ---------------------------------------------------
Excel.Visible = True
If FileExists(App.Path + "\excelfile.xls"

Then
Excel.Workbooks.Open App.Path + "\excelfile.xls"
'Read the name of the sheet
LastMethod = Excel.ActiveWorkbook.Sheets(1).Name
Set ExcelSheet = Excel.ActiveWorkbook.Sheets(LastMethod)
Else
Excel.Workbooks.Add (xlWBATWorksheet)
Set ExcelSheet = Excel.ActiveWorkbook.Sheets("Sheet1"

'fill the sheet
'first with a heading
ExcelSheet.Range("A1

1"

.Font.Bold = True
'then the cells
ExcelSheet.Cells(1, 1).Value = "Datum/tijd"
ExcelSheet.Range("A1"

.ColumnWidth = Len("Datum/tijd"

ExcelSheet.Cells(1, 2).Value = "Pad"
ExcelSheet.Range("B1"

.ColumnWidth = Len(App.Path)
ExcelSheet.Cells(1, 3).Value = "Methode"
ExcelSheet.Cells(1, 4).Value = "Tijdsduur"
ExcelSheet.Cells(1, 5).Value = "Patientnumber"
ExcelSheet.Range("E1"

.ColumnWidth = Len("Patientnumber"

ExcelSheet.Cells(1, 6).Value = "AB1"
ExcelSheet.Cells(1, 7).Value = "AB2"
ExcelSheet.Cells(1, 8).Value = "AB3"
ExcelSheet.Cells(1, 9).Value = "AB4"
ExcelSheet.SaveAs (MakePathStr(App.Path, "excelfile.xls", "xls"

) 'own routine
End If
Set Excelsheet = Nothing
End Sub
'Cancel
Private Sub Exit_btn_Click()
'Only shut down Excel if it wasn't running before.
If bWasntRunning Then
Excel.Quit
End If
'The Quit method closes Excel, but it's still in memory,
'because Excel still points to it. This statement
'will remove it from memory unless it was running when
'this procedure started.
Set Excel = Nothing
Unload Me
End Sub