R
RLN
RE:Access 2003/Excel 2003
I have the following code that runs on the click event of one of my forms.
This code accepts an Excel file as a parm, opens an instance of Excel, does
a simple modification of column length, and saves the file.
The instance of Excel is closed and the Excel object is destroyed.
Problem: After this module runs, (& Excel instance is removed from the
taskbar), I go out to task manager, ...lo and behold an instance of Excel is
still in memory. I like to 'clean up' after working, so how can I get rid of
this instance of Excel that is still in memory?
Code follows:
<begin code>
Public Sub ExportCurrentData (strFile)
Dim objXL As Excel.Application
Set objXL = New Excel.Application
With objXL
'.Visible = False 'Use for Production
.Visible = True 'use this to see actual steps being processed in
XLS file
.Workbooks.Open strFile
'maximize all column lengths
.Columns("A:AG").EntireColumn.AutoFit
.Range("A1").Select 'place cursor in this cell before saving...
.ActiveWorkbook.Save
.Workbooks.close
.Quit
End With
Set objXL = Nothing 'destroy the object to remove from memory
End Sub
<end code>
I have the following code that runs on the click event of one of my forms.
This code accepts an Excel file as a parm, opens an instance of Excel, does
a simple modification of column length, and saves the file.
The instance of Excel is closed and the Excel object is destroyed.
Problem: After this module runs, (& Excel instance is removed from the
taskbar), I go out to task manager, ...lo and behold an instance of Excel is
still in memory. I like to 'clean up' after working, so how can I get rid of
this instance of Excel that is still in memory?
Code follows:
<begin code>
Public Sub ExportCurrentData (strFile)
Dim objXL As Excel.Application
Set objXL = New Excel.Application
With objXL
'.Visible = False 'Use for Production
.Visible = True 'use this to see actual steps being processed in
XLS file
.Workbooks.Open strFile
'maximize all column lengths
.Columns("A:AG").EntireColumn.AutoFit
.Range("A1").Select 'place cursor in this cell before saving...
.ActiveWorkbook.Save
.Workbooks.close
.Quit
End With
Set objXL = Nothing 'destroy the object to remove from memory
End Sub
<end code>