• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 5735
  • Last Modified:

Automation error using CreateObject("InternetExplorer.Application")

I'm using the following code in VBA:

    Dim IE As Object
    Set IE = CreateObject("InternetExplorer.Application")

I've also tried:

    Dim IE As Object
    Set IE = New InternetExplorerMedium

I always finish with:

    Set IE = Nothing

But I randomly get an "Automation Error" (usually is fine except for about 1 quarter of the time):

Run-time error '-2147023706 (8000704a6)':

Automation error
A system shutdown has already been scheduled.

Seems like IE is not closing properly sometimes.
2 Solutions
I know, it is logical to call IE.Quit, however, it is undocumented. You will argue that the method exists, and it is even in their sample on the very page I have referred to, but maybe it is not documented for a reason. What happens if you just do not call it? Just call  Set IE = Nothing and get the garbage collector to take care of disposing the object
Big MontySenior Web Developer / CEO of ExchangeTree.org Commented:
silly question, but have you rebooted since getting the error?
intoxicated_curveballAuthor Commented:
Rebooting or waiting a few minutes seems to always work. But I'm using this frequently so that's only a temp solution. Seems to have something to do with the object or process still running enough though it shouldn't be?
QlemoBatchelor, Developer and EE Topic AdvisorCommented:
chaau: Quit() is documented, but on a different page: https://msdn.microsoft.com/en-us/library/ms970456.aspx.

intoxicated_curveball, the object might be busy, so check for IE.Busy prior to trying to quit, or call IE.Stop.
Do you have to use IE, or might the WebClient class serve the same purpose better? It doesn't require to perform all the rendering needed by IE for visual presentation.
Martin LissOlder than dirtCommented:
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now