问题
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.
回答1:
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.
来源:https://stackoverflow.com/questions/30624518/how-to-close-an-internet-explorer-instance-inside-an-excel-vba