How to close an instance of Internet Explorer in Excel VBA

I am running an Excel VBA macro that opens an instance of IE, retrieves data from a URL, and then has to close the instance again.

Dim IE As Object
Set IE = CreateObject("InternetExplorer.Application")
Set IE = GetObject("new:{D5E8041D-920F-45e9-B8FB-B1DEB82C6E5E}")
' Do stuff...
' Clean up
IE.Quit
Set IE = Nothing

I looked at this method and should close the IE instance. However, this does not work for me. Task Manager confirms that the process iexplorer.exeis still running. If I run the macro several times, a new instance is added and never closed.

How to force a macro to close an instance correctly?

I am using IE 8.0 and VBA 7.0 on this.

+4
source share
1 answer

As the @Sorceri status is correct in the comments, I created two instances. The following code closes the instance without problems.

Dim IE As Object
Set IE = GetObject("new:{D5E8041D-920F-45e9-B8FB-B1DEB82C6E5E}")
' Do stuff...
' Clean up
IE.Quit
Set IE = Nothing

- () , 2 , .

+6

All Articles