G
Guest
I use the following code in Access to open an instance of Excel to do some
worksheet operations and close Excel at the end:
Dim appXL As Excel.Application
Set appXL = CreateObject("excel.application")
appXL.Visible = True
.... code to open excel file, do some simple operations, save file ...
appXL.Quit
Set appXL = Nothing
When the macro is done, it seems like Excel closed normally (gone from task
bar), but in fact there's still an instance of Excel in the Process tab of
Task Manager (Application tab shows no Excel).
If I run the same macro again the second time, it basically crashes at the
first line after opening the spreadsheet file. I get the message:
Run-time error '1004': Method 'Cells' of object '_Global' failed
And I see 2 Excel listed in Process tab of Task Manager, with only 1 Excel
in Application tab, also 1 Excel in taskbar at the bottom of screen.
I did notice that if I press the Reset button in the VBA window after
running the macro, that Excel instance in Task Manager would truely exit.
After that I can run the same macro a second time with no problem.
That means I would need to press the Reset button each time after running
the macro, if I wanted to run the same macro again without crashing. I can't
expect the user to do the same thing. So I would like to know what's causing
that problem and if there's a way around it.
By the way, I am using Office 2003. It would also be helpful to know if
others with the same version have the same problem. If I'm the only one then
maybe it's a problem with my system rather than code problem. Thanks for
helping.
-Simon
worksheet operations and close Excel at the end:
Dim appXL As Excel.Application
Set appXL = CreateObject("excel.application")
appXL.Visible = True
.... code to open excel file, do some simple operations, save file ...
appXL.Quit
Set appXL = Nothing
When the macro is done, it seems like Excel closed normally (gone from task
bar), but in fact there's still an instance of Excel in the Process tab of
Task Manager (Application tab shows no Excel).
If I run the same macro again the second time, it basically crashes at the
first line after opening the spreadsheet file. I get the message:
Run-time error '1004': Method 'Cells' of object '_Global' failed
And I see 2 Excel listed in Process tab of Task Manager, with only 1 Excel
in Application tab, also 1 Excel in taskbar at the bottom of screen.
I did notice that if I press the Reset button in the VBA window after
running the macro, that Excel instance in Task Manager would truely exit.
After that I can run the same macro a second time with no problem.
That means I would need to press the Reset button each time after running
the macro, if I wanted to run the same macro again without crashing. I can't
expect the user to do the same thing. So I would like to know what's causing
that problem and if there's a way around it.
By the way, I am using Office 2003. It would also be helpful to know if
others with the same version have the same problem. If I'm the only one then
maybe it's a problem with my system rather than code problem. Thanks for
helping.
-Simon