VBA script to close every instance of Excel except itself

前端 未结 6 925
忘掉有多难
忘掉有多难 2020-12-04 00:07

I have a subroutine in my errorhandling function that attempts to close every workbook open in every instance of Excel. Otherwise, it might stay in memory and break my next

6条回答
  •  感动是毒
    2020-12-04 00:44

    Differentiating open instances of an application is a very old problem, and it is not unique to VBA.

    I've tried to figure this out myself over the years, never with greater success than the time before.

    I think the long and short of it is that you can never know if the application instance you're referencing is the one in which the code is executing (so terminating it might leave other instances open).

提交回复
热议问题