View Single Post
  #9   Report Post  
Posted to microsoft.public.excel.programming
JP[_4_] JP[_4_] is offline
external usenet poster
 
Posts: 897
Default Very Slow reading excel data into an array (while opened in ne

But why are we even creating a new instance of the Excel application
at all? This code is running natively inside Excel (if I assume
correctly).

--JP


On Sep 13, 10:26*am, Joel wrote:
I believe this is a memory leak

* *Set xl = Nothing

You aren't releasing any memory. *All you are doing is setting the variable
xl to nothing. *The memory is still allocated to the program.

Try this

Sub MyMacro()
Dim xl
Set xl = CreateObject("word.application")
xl.Visible = True
Set xl = Nothing

End Sub

The word document stays opened. *Close the word document manually. *If the
object was invisiable it would still be running. *You can prove this by not
making the object visible and creating the object in the code above. *Then go
to Task Manager. *You will still see Word running. *Just because you cna't
see it running doesn't mean that it is NOT running.

Now this

Sub MyMacro()
Dim xl
Set xl = CreateObject("word.application")
xl.Visible = True

xl.Quit

End Sub