Try this sort of thing all throughout your project:
VB Code:
Dim objXLApp as Excel.Application Set objXLApp = new Excel.Application If not (objXLApp is nothing) then ' Object's created fine - run code against it here objXLApp.workbooks(1).close objXLApp.Quit Set objXLApp = nothing End If
By doing this, you avoid errors when you check the objects are open/created before you use them, and you release them from memory shen they are no longer needed (most objects will have some kind of close() or exit() etc. method you can call & you should always use the "Set xyz = nothing" call when you're finished with an object)...




Reply With Quote