Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to close an Internet Explorer instance inside an Excel VBA

I'm running an Excel VBA macro which opens a IE instance, extracts data from a URL and then is supposed 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 up that method and it is supposed to close the IE instance. However that does not work for me. The task manager confirms that the iexplorer.exe process is still running. If I run the macro several times a new instance is added and never closed.

How can I make the macro properly close the instance?

I'm using IE 8.0 and VBA 7.0 on this.

like image 443
Access Avatar asked Jun 03 '15 15:06

Access


1 Answers

As @Sorceri statet correct in the comments, I have created two instances. The following Code quits 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

Interesting about the above (wrong) code is, that he indeed opens 2 instances, but does not close either of them at the end.

like image 178
Access Avatar answered Oct 08 '22 20:10

Access