Private Sub WriteToExcel(ByVal filename As String) Dim MyExcel As New Excel.Application Dim oWorkbooks As Excel.Workbooks = MyExcel.Workbooks() Dim theWorkbook As Excel.Workbook = oWorkbooks.Add() Dim oSheet As Excel.Worksheet 'If file already exists, remove it 'If File.Exists(xlsSaveFile) Then File.Delete(xlsSaveFile) Try theWorkbook = oWorkbooks.Open("C:\cbcs.xls") oSheet = MyExcel.ActiveSheet oSheet.Name = "Inventory List" oSheet.Range("B4").Value = "Cabling" oSheet.Range("C4").Value = "100" oSheet.Range("D4").Value = "0.26" theWorkbook.SaveAs("C:\cbcs2.xls") theWorkbook.Close() MyExcel.Quit() MyExcel = Nothing GC.Collect() GC.WaitForPendingFinalizers() Catch ex As Exception Throw New Exception("Error creating Excel spreadsheet:" & ex.Message.ToString()) Finally oSheet = Nothing theWorkbook = Nothing oWorkbooks = Nothing MyExcel = Nothing End Try