This is just a program that just adds some text into a cell on both sheet1 and sheet2.
Option Explicit
'Add a reference to MS Excel xx.0 Object Library
Private moApp As Excel.Application
Private moWB As Excel.Workbook
Private Sub Form_Load()
Set moApp = New Excel.Application
moApp.Visible = False
End Sub
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
If TypeName(moWB) <> "Nothing" Then
moWB.Close True, "C:\Text.xls"
End If
Set moWB = Nothing
If TypeName(moApp) <> "Nothing" Then
moApp.Quit
End If
Set moApp = Nothing
End Sub
Private Sub Command1_Click()
Set moWB = moApp.Workbooks.Add
moApp.Visible = True
moWB.Sheets("Sheet2").Cells(1, 1).Value = "Added from VB6"
moWB.Sheets("Sheet1").Cells(1, 1).Value = moWB.Sheets("Sheet2").Cells(1, 1).Value
End Sub