How does the "VBA research" method quit acting on IWebBrowser2 failure?

Source: Internet
Author: User

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?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.