Reputation: 381
So I have an internet explorer object, and I'm using it to get a DOM object after navigating to a page. (Actually, I'm getting a collection of DOM Form Objects, but I'm trying to keep the question as generic as possible.)
Set ie = CreateObject("InternetExplorer.Application")
ie.navigate (URL)
Set DOM = ie.document
Then i want to quit ie a la ie.quit
, and continue working with my new DOM object. Unfortunately, quitting ie seems to empty out the dom object of all it's contents. Is there a way to stop this from happening? I really don't want to leave ie open until the end of the program as it a) is a resource hog, and b) tends to lead to a lot of unclosed instances in the event of errors further down the line. Thanks, and sorry if the answer turns out to be really obvious (which it feels like it might be, although I REALLY did hunt around.)
Upvotes: 0
Views: 178
Reputation: 24341
I don't think you can quit IE at the point where you are holding the object. Unless I'm missing something, you're holding a reference to a COM object; the COM object isn't stored in your application but managed by IE, so when throw away IE, you throw away your object with it.
I would attempt to hold onto the DOM for the shortest time possible if you are concerned about resource utilization, but if you need access to the DOM, you need to keep IE around.
If you only need parts of the data, you can of course always pull out the relevant bits from the DOM, get rid of IE and work on the data you just pulled out.
Upvotes: 1
Reputation: 61666
The DOM lives in the Internet Explorer process address space, which is separate from your application. What your have on your side is just in-process proxies objects for external out-of-process DOM objects. By doing ie.quit
you effectively terminate the IE process and cut off its DOM.
It is also not clear from your code if you wait for DocumentComplete
event before accessing the DOM. You certainly can't access it right away after calling Navigate
.
Upvotes: 1