while creating Excel files in vb.net, all is fine, except when I want to close my PC and there are many popups to save or delete "bookx.xls". How do I prevent these blank books from being made??
THanks,
Printable View
while creating Excel files in vb.net, all is fine, except when I want to close my PC and there are many popups to save or delete "bookx.xls". How do I prevent these blank books from being made??
THanks,
Well that all depends on what your code is doing.
this is basically the code I use to create it, then as I create data, I open and add sheets to it and close again.. so how do I stop it from creating ghost books???
vb Code:
Public Sub Create_Excel_File(ByVal sPath As String, ByVal sName As String) Dim pExcel_App As Excel.Application Dim pExcel_Wkbook As Excel.Workbook Dim wkbSheet As Excel.Worksheet Try pExcel_App = New Excel.Application pExcel_Wkbook = pExcel_App.Workbooks.Add '== add worksheet to file wkbSheet = pExcel_Wkbook.Worksheets.Add Dim sOutExcelPath As String sOutExcelPath = sPath & "\" & sName pExcel_Wkbook.SaveAs(sOutExcelPath) pExcel_App.DisplayAlerts = False pExcel_App.ActiveWorkbook.Close(SaveChanges:=True, Filename:=sOutExcelPath) pExcel_App.Quit() Catch ex As Exception MsgBox("ERROR: " & m_Current_Address & " - Create Excel log file for - " & mDistrictName & " - " & ex.Message) Finally pExcel_App = Nothing pExcel_Wkbook = Nothing wkbSheet = Nothing End Try End Sub