Using an IE browser with Visual Basic

南笙酒味 提交于 2019-12-02 00:56:05
brettdj

You could try something like this, drawing heavily on reusing Internet Explorer COM Automation Object to identify an instance of IE with then specific web page active that you are looking for.

Change
strURL = "http://www.theage.com.au/"
to

"My Page Title - Windows Internet Explorer" as necessary

VBA

Sub Test()
Dim ShellApp As Object
Dim ShellWindows As Object
Dim IEObject  As Object
Dim strURL As String
strURL = "http://www.theage.com.au/"
Set ShellApp = CreateObject("Shell.Application")
Set ShellWindows = ShellApp.Windows()
Dim i
For i = 0 To ShellWindows.Count - 1
    If InStr(ShellWindows.Item(i).FullName, "iexplore.exe") <> 0 Then
        If ShellWindows.Item(i).LocationURL = strURL Then
            Set IEObject = ShellWindows.Item(i)
            MsgBox "IE instance with " & strURL & " found"
            Exit For
        End If
    End If
Next
End Sub
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!