Hi,
I created an Excel application within Access 97.
However, the Excel still remains in the memory after running the following code. This causes Excel sheet(s) not visible if I open another Excel file.
Could anybody help?
Thanks in advance.
dynasty
-------------------------------------------
Private Sub TestExcel
Dim xlApp As Excel.Application
Dim xlBook As Excel.Workbook
Dim MySheet As Excel.Worksheet
'Create object if not exist
Err.Number = 0
On Error GoTo notloaded
Set xlApp = GetObject(, "excel.Application.8"
notloaded:
If Err.Number = 429 Then
Set xlApp = CreateObject("excel.Application.8"
End If
xlApp.Workbooks.Add
Set xlBook = xlApp.ActiveWorkbook
Set MySheet = xlBook.Worksheets("Sheet1"
MySheet.cell(1,1) = "Hello World"
xlBook.SaveAs "C:\MyFolder\Testfile.xls"
'Clean up
Set MySheet = Nothing
Set xlBook = Nothing
xlApp.Quit
Set xlApp = Nothing
End Sub
I created an Excel application within Access 97.
However, the Excel still remains in the memory after running the following code. This causes Excel sheet(s) not visible if I open another Excel file.
Could anybody help?
Thanks in advance.
dynasty
-------------------------------------------
Private Sub TestExcel
Dim xlApp As Excel.Application
Dim xlBook As Excel.Workbook
Dim MySheet As Excel.Worksheet
'Create object if not exist
Err.Number = 0
On Error GoTo notloaded
Set xlApp = GetObject(, "excel.Application.8"
notloaded:
If Err.Number = 429 Then
Set xlApp = CreateObject("excel.Application.8"
End If
xlApp.Workbooks.Add
Set xlBook = xlApp.ActiveWorkbook
Set MySheet = xlBook.Worksheets("Sheet1"
MySheet.cell(1,1) = "Hello World"
xlBook.SaveAs "C:\MyFolder\Testfile.xls"
'Clean up
Set MySheet = Nothing
Set xlBook = Nothing
xlApp.Quit
Set xlApp = Nothing
End Sub