简体   繁体   English

Internet Explorer在Excel VBA中完成加载后运行功能

[英]Run a function after internet explorer finishes loading in Excel VBA

Function GetIE() As Object
  On Error Resume Next
  Set GetIE = CreateObject("InternetExplorer.Application")
End Function

Dim appIE As Object ' InternetExplorer.Application
Dim sURL As String

sURL = "https://xxx.xxx.xxx.xxx/pppp/"

Application.ScreenUpdating = False

Set appIE = GetIE
appIE.Visible = True

With appIE
    .navigate sURL & "login.php"
    .Visible = True
End With

I want to call a function after internet explorer finishes loading. 我想在Internet Explorer完成加载后调用一个函数。 How do I do that? 我怎么做?

With appIE
    .navigate sURL & "login.php"
    .Visible = True

    ' Enter a do loop until the *readyState* property of IE object becomes equal to 4
    Do
        If .readyState = 4 Then ' check the *readyState* property
            ' Call your function here
            Exit Do
        Else
            ' IE is not ready, allow other application events to run
            DoEvents
        End If
    Loop

End With

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM