'SAVE DATA INTO existing EXEL FILE
'Creating Excel application object
Dim EXL As New Excel.Application
'Checking if Excel object initiated succesfully or not
If EXL Is Nothing Then
MsgBox("Couldn't start Excel")
Exit Function
End If
'Creating Excel Worksheet
Dim WSheet As New Excel.Worksheet
opening worksheet to excel workbooks
WSheet = EXL.Workbooks.Open("[b]source[/b]").Worksheets.Item(1)
'Writing values in Work Sheet
With WSheet
.....................
End With
Try
'Saving .xls file with Test.xls name
Dim File2 As System.IO.File
Dim PATH2 As String = "[b]source[/b]"
WSheet.SaveAs(PATH2)
Catch
End Try
'setting up caption that "File Created"
Me.Text = "File Created"
'closing down workbook
EXL.Workbooks.Close()
EXL.Quit()
While System.Runtime.InteropServices.Marshal.ReleaseComObject(EXL) <> 0
End While
EXL = Nothing
GC.Collect()
GC.WaitForPendingFinalizers()
End Function