[英]Internet Explorer child window in VBA
我有一個VBA代碼,可單擊IE頁面上的鏈接並打開一個新窗口。 如何獲得該子窗口的元素?
我嘗試了Shell.application。 還有其他方法嗎?
Set objShell = CreateObject("shell.application")
IEcount= objShell.Windows.Count
For x = 0 To iecount
On Error Resume Next
Debug.Print x, objShell.Windows(x).document.Location
Next x
我得到了窗口號及其URL,但是無法訪問頁面上的元素。
查看我在您的代碼中插入的“ if-then”語句。 您可以使用標題或URL來標識子項並對其進行設置。 一旦獲得焦點,就可以獲取子窗口的元素。
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_title Like "Something that identifies your child window" Then
Set ie = objShell.Windows(x)
Exit For
Else
End If
Next
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.