Iamlaosong
The use of VBA programming to automatically read Web page data, during the reading process to close the Web page encountered an error: "Method Quit action IWebBrowser2 failed", unable to execute the Quit method, but the other properties are not a problem, the best solution, the source code is as follows:
Sub login3 () Dim ie1 as Object Lineno = [A65536]. End (Xlup). Row ' number of rows for row1 = 2 to Lineno ems_id = Trim (Cells (Row1, 1)) Set ie1 = CreateObject ("Internetexplorer.app Lication ") ie1. Visible = True ie1.navigate "http://10.3.10.83/ems/newsystem/thesecond/ttq/ttqMailquery.jsp" do Until ie1. Readystate = 4 DoEvents Loop ie1.document.Forms (0). All ("Mailnum"). Value = ems_id ie1.document.Forms (0). Submit If MsgBox ("& Row1-1 &" Mail query complete, continue ... ", vbOKCancel," Ah Ems:iamlaosong ") = vbcancel then Exit Sub ie1. Quit ' This sentence error ' Debug.Print Ie1.document.DocumentElement.outerHTML ' Display page source code ' Debug.Print Ie1.document.body.innertext ' Display Web page text message ' rethtml = Ie1.document.DocumentElement.outerHTML Next row1 End Sub
Search on the Internet, but also someone raised a similar problem, but did not find the problem, some people say that can be normal execution, some people say no, also some people say sometimes, sometimes not, think carefully, doubt is the reason for the browser, when the problem, open is 360 browser, ie may be on the line, so, Replace the default browser with IE8 and run the program again, the problem no longer occurs.
Conclusion: This method can close IE browser, the other browser is feasible, need to test.
How does the "VBA research" method quit acting on IWebBrowser2 failure?