aut*_*en7 1 excel vba excel-vba navigateurl
目前的代码如下:
Set IE = CreateObject("InternetExplorer.Application")
IE.Navigate "https://www.website.com/"
Application.StatusBar = "https://www.website.com/ is loading. Please wait..."
Do While IE.Busy
Application.Wait DateAdd("s", 1, Now)
Loop
Application.StatusBar = "Search form submission. Please wait..."
Run Code Online (Sandbox Code Playgroud)
我遇到的问题是" https://www.website.com/ "无法不时加载(我相信这是由于我反复访问它).结果是代码永远不会超出这个循环:
Do While IE.Busy
Application.Wait DateAdd("s", 1, Now)
Loop
Run Code Online (Sandbox Code Playgroud)
在我看来,一个逻辑解决方案是在达到一定的时间限制(30秒?)后杀死IE并重启整个过程.请告知如何编写此解决方案,和/或如何编写更有效的解决方案.非常感谢你!我正在使用IE10,如果这很重要的话.
此外,这里有一个链接我发现有一些相关和相关的信息:http: //www.ozgrid.com/forum/showthread.php?t = 161094
您可以尝试修改要读取的代码
Sub LoadWebsite()
Dim iSecondCounter As Integer
Static iAttempts As Integer
iAttempts = iAttempts + 1
Set ie = CreateObject("InternetExplorer.Application")
ie.Navigate "https://www.website.com/"
Application.StatusBar = "https://www.website.com/ is loading. Please wait..."
iSecondCounter = 0
Do While ie.Busy And iSecondCounter < 30
Application.Wait DateAdd("s", 1, Now)
iSecondCounter = iSecondCounter + 1
Loop
If iSecondCounter = 30 Then
ie.Quit
If iAttempts <= 3 Then Call LoadWebsite
End If
Set ie = Nothing
End Sub
Run Code Online (Sandbox Code Playgroud)