what is the code that closes all the "already open" excel files and exits the excel application in vb?
To be specific, I have the following code that opens the excel file at MySource
Set objExcel = GetObject(MySource)
objExcel.Application.Visible = False 'Excel is not shown
objExcel.windows(1).Visible = True
In case MySource is already opened by the users. My code cannot be run. Since it is said that Excel cannot open the same file twice at the same time. I want to close all the "already opened" excel file and also close the Excel application so that my code can be run smoothly.
Any idea? Thanks