VBA Internet Explorer Automation 'Permission Denied'

后端 未结 8 1328
别那么骄傲
别那么骄傲 2020-12-19 23:11
Dim IE as New InternetExplorer
IE.Visible = True

IE.Navigate(\"http://www.google.com\")

Do Until IE.Busy = False
Loop

IE.document.getElementsByTagName(\"Input\")(         


        
8条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-19 23:50

    The following worked for me. I haven't tested it extensively, but the problem hasn't recurred. I was getting the error intermittently, but always at same point.

    Control of the first IE instance seems to die. However, another instance can be created by referencing the first. The dead instance can then be closed, and we carry on.

    Set IEa = CreateObject("InternetExplorer.Application")
    Set IEa = IE
       'Where IE is the instance that's about to error
    SendKeys ("%{F4}")
       'Closes the old window, IE.quit in the code wouldn't work
    IEa.Visible = True
    

    Hope this works for someone else, I was getting pretty frustrated.

    Brian

    PS: My first post on stackoverflow, I think I did the formatting right

提交回复
热议问题