无法找到通过VMWare打开的IE窗口

时间:2019-08-30 04:32:37

标签: excel vba vmware-workstation

我正在使用下面的Excel VBA代码使用 shell.Application 对象根据URL或窗口标题找到Internet Explorer窗口。

Function findPage() As SHDocVw.InternetExplorer

Dim objShell As Object
Dim IE As SHDocVw.InternetExplorer
Dim doc As MSHTML.HTMLDocument
Dim Marker, x, IE_count As Integer
Dim my_url, my_title As String

Marker = 0
Set objShell = CreateObject("Shell.Application")
IE_count = objShell.Windows.Count

For x = 0 To (IE_count - 1)
    On Error Resume Next    ' sometimes more web pages are counted than are open
    my_url = objShell.Windows(x).document.Location
    my_title = objShell.Windows(x).document.Title


    If my_url Like "*/SampleUrl/*" Then 'compare to find if the desired web page is already open
        Set IE = objShell.Windows(x)
        Marker = 1
        Exit For
    Else
    End If
Next

If Marker = 0 Then
    MsgBox ("A matching webpage was NOT found")
Else
    'Debug.Print "A matching webpage was found"
End If

Set findPage = IE
End Function

我可以找到所有其他窗口,但不能找到通过VMWare打开的IE窗口。有什么方法可以找到通过Virtualization软件打开的IE窗口吗?

请澄清。

0 个答案:

没有答案