Controlling Excel in VB - close method
Posted on 2003-02-20
I am writing an application in visual basic and use an excel sheet to build up a preview to eventually print out. I've got a "create preview" button in my vb app to show the excel file generated with data from a flexgrid in my vb application. Everything works fine, it fits, it looks like i want it to look etc, except for one thing. If i close the preview, and go back to my vb application and click the "create preview" button again, the generated excel file will open again BUT it won't show the data, instead it will show me the usual "File, Edit etc" menu but where the data should be, i see the background, behind that excel file, locked. Which is most of the time my own application. I debugged it and i don't get any errors and everything gets written to the cells, it just won't show it the second time. Yes, i've set the excel object to nothing at the end.
What i do notice though is when i close the excel object in my code (excelobject.close) after the preview has been generated and press the button again, it will show up as it's supposed to. Only one problem, closing it in the code will also close the excel window and i don't want that. I want the user to close it, and then still being able to click it again. I thought that when the user closed the excel window, it would equal the close method?
i've been trying a lot of things to get past that problem but in vain. Can someone help me?