以下代码是查找到某个 ie窗口,再对这个ie窗口的网页元素访问,但我的代码无法实现这功能。请大家帮我看一下。谢谢! Dim dWinFolder As SHDocVw.ShellWindows dWinFolder = New SHDocVw.ShellWindows Dim objIE1 As SHDocVw.InternetExplorer Dim ActID As Long Dim tmp_doc As Object Dim tmp_1 objIE1 = New SHDocVw.InternetExplorer() ActID = FindWindow("IEFrame", vbNullString) For Each objIE1 In dWinFolder tmp_doc = TypeName(objIE1.Document) If tmp_doc = "HTMLDocument" Then' z这里得到tem_docw为HTMLDocumentClass MsgBox("afda") End If My.Computer.FileSystem.WriteAllText("c:\testfile.txt", _ " " + objIE1.LocationURL, True) '过滤掉windows资源管理器的窗口 If InStr(1, objIE1.FullName, "IEXPLORE.EXE", vbTextCompare) <> 0 Then '是否是当前正在浏览的IE窗口 If objIE1.HWND = ActID Then My.Computer.FileSystem.WriteAllText("c:\testfile.txt", _ " = " + objIE1.LocationURL, True) '执行程序 'myUrl = objIE1.LocationURL '取得地址 If Trim(objIE1.LocationURL) = "网址" Then '下面几个id网页页面都存在 objIE1.Document.getElementById("randMobile").value = "1316465464" objIE1.Document.getElementById("get_checkcode").click() Exit For End If End If End If Next getIeObject = objIE1 End Function