Board index » Visual Studio » Closing Automated Excel

Closing Automated Excel

Visual Studio147
I am using Automation in VB6 to open an Excel

spreadsheet, read in it's contents and then I want to

close it down. I use appExcel.Quit and the set appExcel

to nothing. The Excel object still shows up in the Task

Manager until I shut my program down. How can I get

Excel to close without shutting down my program?



Thank!


-
 

Re:Closing Automated Excel

Do you close the Workbook first? If not, Excel may be waiting for you to

save its changes.



Excel is also VERY sensitive to errors triggered from, but not handled by, a

VB app. Particularly if Excel is not visible or has DisplayAlerts set to

false. A common cause is a bad argument to an Excel function -- you get no

message that something is wrong, but (as you observe) Excel refuses to

close.





"Chuck" <anonymous@discussions.microsoft.com>wrote in message

Quote
I am using Automation in VB6 to open an Excel

spreadsheet, read in it's contents and then I want to

close it down. I use appExcel.Quit and the set appExcel

to nothing. The Excel object still shows up in the Task

Manager until I shut my program down. How can I get

Excel to close without shutting down my program?



Thank!





-

Re:Closing Automated Excel

Chuck,



When you start your excel executing, set the visible flag. When you quit (Or

what you think you have quit), see if an error message pops up.



If no messages appears, try creating an EXE and running it and see what

happens.



I have had this same issue when I run it from within the IDE. Excel does not

go away until after I exit VB. I am making the assumption that VB is keeping

a reference.



I have found it similar to when I create and test DLLs. If I have an

application referencing a DLL and run it via the IDE; when I stop, the I can

not recreate the DLL file. I have to leave the testing application before I

can recreate the DLL.





I hope that helps.





"Chuck" <anonymous@discussions.microsoft.com>wrote in message

Quote
I am using Automation in VB6 to open an Excel

spreadsheet, read in it's contents and then I want to

close it down. I use appExcel.Quit and the set appExcel

to nothing. The Excel object still shows up in the Task

Manager until I shut my program down. How can I get

Excel to close without shutting down my program?



Thank!





-

Re:Closing Automated Excel

On Wed, 5 Nov 2003 11:54:12 -0800, "Chuck" <anonymous@discussions.microsoft.com>wrote:



¤ I am using Automation in VB6 to open an Excel

¤ spreadsheet, read in it's contents and then I want to

¤ close it down. I use appExcel.Quit and the set appExcel

¤ to nothing. The Excel object still shows up in the Task

¤ Manager until I shut my program down. How can I get

¤ Excel to close without shutting down my program?



Make certain to set a variable to any object you create or reference. Implicit object references

will cause Excel to remain in memory.





Paul ~~~ pclement@ameritech.net

Microsoft MVP (Visual Basic)

-