Hi,
I was wondering if one the smart people that frequent this group could
give me a hand with a small program I am attempting to debug.
I am not a highly experienced developer, but can create small
programs.
I was asked to write a small application that would look in a folder,
and convert all the CSV files to XLS.
I thought about using a macro, but they did not want that. Fine.
I wrote a small program in VB .NET (2003, I do nto have 2005 yet).
The program does the following:
For each select file in a list box
delete the existing XLS file, if there
Create a new Excel.Application
The source I used is as follows:
Private myExcelFile As Excel.Application (at the top of the file)
myExcelFile = New Excel.Application
xlConvert(oldFileName, newFilename)
The function called (xConvert) has the following:
******* begin source
Try
tFileNameCSV = MySrcPath + "\" + oldFileName
tFileNameXLS = MySrcPath + "\" + newFileName
' Open the CSV file
'myExcelFile = New Excel.Application
myExcelFile.Visible = False
myExcelFile.Workbooks.Open(MySrcPath + "\" + oldFileName)
'Turn off message box so that we do not get any messages
myExcelFile.DisplayAlerts = False
'Save the file as XLS file
myExcelFile.ActiveWorkbook.SaveAs(Filename:=MySrcP ath +
"\" + newFileName, FileFormat:=Excel.XlFileFormat.xlExcel9795,
CreateBackup:=False)
'Close the workbook
myExcelFile.ActiveWorkbook.Close(SaveChanges:=Fals e)
'Turn the messages back on
myExcelFile.DisplayAlerts = True
'Quit from Excel
myExcelFile.Quit()
'Kill the variable
myExcelFile = Nothing
******* end source
The problem is that, as the files get converted, more an more memory
is being used (I am converting about 116 files right now).
Even after I close the executable, there is still a bunch of memory
being used.
Looking in the task manager, I could see at one time about 20 copies
of Excel.exe in memory.
After a while, it settles down to 11 copies in memory.
But I thought that, after quitting Excel and setting the variable to
"nothing", that this would free up my memory.
Any ideas as to what I am doing wrong?
Thank you in advance.
André