|
-
Nov 12th, 2009, 10:34 AM
#1
Thread Starter
Addicted Member
using Excel keeps adding books
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,
-
Nov 12th, 2009, 12:04 PM
#2
Re: using Excel keeps adding books
Well that all depends on what your code is doing.
-
Nov 16th, 2009, 09:05 AM
#3
Thread Starter
Addicted Member
Re: using Excel keeps adding books
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
Last edited by Hack; Nov 16th, 2009 at 12:04 PM.
Reason: Added Highlight Tags
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|