Hi~
I am opening an instance of excel 2000 with access 2000 pulling some data into the database and closing Excel. The only problem is after I run my code, excel is still running in the background (I can see it in task manager but not in the task bar). PLEASE help me solve this major memory leak!! Here is the valid code:
Option Compare Database
Option Explicit
Private Sub Command0_Click()
Dim objXL As Object
Dim xlWB As Object
Dim xlWS As Object
'some objects to refer to Excel
Dim db As DAO.Database
Dim sample_info As DAO.Recordset
Dim species_comp As DAO.Recordset
Dim bio_vol As DAO.Recordset
Dim letter_look As DAO.Recordset
Dim sample_look As DAO.Recordset
Dim genus_look As DAO.Recordset
Set db = CurrentDb
Set sample_info = db.OpenRecordset("TEST_Sample_Info_FINAL"
'open our recordsets
Set species_comp = db.OpenRecordset("TEST_Species_Composition_Data_FINAL"
Set bio_vol = db.OpenRecordset("TEST_BioVolume_Data_FINAL"
Set letter_look = db.OpenRecordset("TEST_Letter_Lookup"
Set sample_look = db.OpenRecordset("Sample_ID_Master"
Set genus_look = db.OpenRecordset("Genus_lookup"
Set objXL = CreateObject("Excel.Application"
Set xlWB = objXL.workbooks.Open("C:\USER\sample.xls"
Set xlWS = xlWB.worksheets("52"
'set references to our excel worksheet
'xlWB.Save 'do not save the spread sheet after grabing the data
xlWB.Close
objXL.Quit
Set xlWS = Nothing
Set xlWB = Nothing
Set objXL = Nothing
sample_info.Close
species_comp.Close
bio_vol.Close
letter_look.Close
sample_look.Close
genus_look.Close
Set sample_info = Nothing
Set species_comp = Nothing
Set bio_vol = Nothing
Set letter_look = Nothing
Set sample_look = Nothing
Set genus_look = Nothing
Set db = Nothing
'tidy up time
End Sub
Any Ideas???
Thanks!
Adam
I am opening an instance of excel 2000 with access 2000 pulling some data into the database and closing Excel. The only problem is after I run my code, excel is still running in the background (I can see it in task manager but not in the task bar). PLEASE help me solve this major memory leak!! Here is the valid code:
Option Compare Database
Option Explicit
Private Sub Command0_Click()
Dim objXL As Object
Dim xlWB As Object
Dim xlWS As Object
'some objects to refer to Excel
Dim db As DAO.Database
Dim sample_info As DAO.Recordset
Dim species_comp As DAO.Recordset
Dim bio_vol As DAO.Recordset
Dim letter_look As DAO.Recordset
Dim sample_look As DAO.Recordset
Dim genus_look As DAO.Recordset
Set db = CurrentDb
Set sample_info = db.OpenRecordset("TEST_Sample_Info_FINAL"
Set species_comp = db.OpenRecordset("TEST_Species_Composition_Data_FINAL"
Set bio_vol = db.OpenRecordset("TEST_BioVolume_Data_FINAL"
Set letter_look = db.OpenRecordset("TEST_Letter_Lookup"
Set sample_look = db.OpenRecordset("Sample_ID_Master"
Set genus_look = db.OpenRecordset("Genus_lookup"
Set objXL = CreateObject("Excel.Application"
Set xlWB = objXL.workbooks.Open("C:\USER\sample.xls"
Set xlWS = xlWB.worksheets("52"
'set references to our excel worksheet
'xlWB.Save 'do not save the spread sheet after grabing the data
xlWB.Close
objXL.Quit
Set xlWS = Nothing
Set xlWB = Nothing
Set objXL = Nothing
sample_info.Close
species_comp.Close
bio_vol.Close
letter_look.Close
sample_look.Close
genus_look.Close
Set sample_info = Nothing
Set species_comp = Nothing
Set bio_vol = Nothing
Set letter_look = Nothing
Set sample_look = Nothing
Set genus_look = Nothing
Set db = Nothing
'tidy up time
End Sub
Any Ideas???
Thanks!
Adam