长时间运行的Excel VBA查询现在导致IE无法响应

时间:2018-06-26 04:58:38

标签: vba

我有一些已经在Excel中建立和维护了多年的工具。他们打开IE,登录到行业数据库,复制回一些信息,然后再次关闭。 Office和IE的最新更新,现在我们经常会在IE打开后立即将其锁定为无响应状态,尤其是多次使用时。

IE版本可以在11.0.56上运行,但不能在11.0.65上运行-但是将其回滚似乎并不能解决问题,因此看起来更广泛的Office更新可能会对其造成影响。

针对不同的工具,有几个不同的代码,但是它们都遇到相同的问题。

这是相关的代码,看起来s breaking it is immediately after IE has been opened. Any help greatly appreciated, as I say has been a reliable bit of code so strange it开始出现这样的问题:

    Option Explicit

Dim IE As InternetExplorer
Dim HTMLForm As HTMLFormElement
Dim HTMLDOC As HTMLDocument
Dim strAddress As String
Dim strWarning As String
Dim booTOU As Boolean
Dim booSmart As Boolean
Dim intCount As Integer
Dim intCount2 As Integer
Dim intRowCount As Integer
Sub RegistryInfo()

On Error Resume Next

'Start
ActiveSheet.Unprotect
Application.ScreenUpdating = False

'open IE

Set IE = New InternetExplorer

' Make IE visible

IE.Visible = False

'Go to the website

IE.navigate "https://www.electricityregistry.co.nz/bin_public/jadehttp.dll?MariaWebR"

'Wait for the page to load

Do Until IE.readyState = READYSTATE_COMPLETE And IE.Busy = False
Loop

' set variables for easy access

Set HTMLDOC = IE.document
Set HTMLForm = HTMLDOC.forms(0)

'Look for username (tabindex : 652) and enter username / Look for password (tabindex : 654) and enter password

For intCount = 0 To HTMLForm.elements.Length - 1

    If HTMLForm.elements(intCount).TabIndex = 652 Then

        HTMLForm.elements(intCount).innerText = ActiveSheet.Range("H2").Value

    ElseIf HTMLForm.elements(intCount).TabIndex = 654 Then

        HTMLForm.elements(intCount).innerText = ActiveSheet.Range("H3").Value

    End If

Next

'Click ok on the web page

For intCount = 0 To HTMLForm.elements.Length - 1

    If HTMLForm.elements(intCount).TabIndex = 655 Then

        HTMLForm.elements(intCount).Click

        Exit For

    End If

Next

1 个答案:

答案 0 :(得分:1)

这是导致问题的WebRoot扩展的更新版本-已将其回滚并解决了问题。