Forum Discussion

lrbehmer's avatar
lrbehmer
Contributor
15 years ago

Script Extensions and Scope

I'm trying to create an "open/close Excel" script extension.  What I'm finding is that script extensions don't act like regular classes and I can't use a script extension to open Excel, perform operations on a spreadsheet in the script, and then close Excel with an extension.



Can I make global objects or is there some other way to handle this?

13 Replies

  • Well, shouldn't it kill the process when the script is done?


  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor
    I'm not entirely sure.  I have a script extension I created for handling SQL queries and I instantiate an ADO.CreateConnection object in there as a global... that object is ALWAYS there, no matter what I do.  So long as there is a variable that contains an instance of Excel.Application, it will always be present in memory.



    So, the simple fact that you have a global variable instantiated as OleObject('Excel.Application') I think means it will always be memory resident until you set that variable to nil or null...  Because it's a run time object, it never goes out of scope and so it never gets reassigned.
  • Oh, so if I run the excel executable manually, I should be able to kill it.