我試圖用我的腳本瞄準一個現有的IE視窗(只有一個標簽)。
換句話說:有一個IE視窗打開了,有一個特定的標簽,我想讓我的腳本用它的標簽名來鎖定這個標簽。 我看了一下這些主題,但沒有一個對我有用(或者我做錯了):
物件不支持此屬性或方法(Error 438)
該錯誤突出顯示了以下一行:
WindowTitle = Application.Document.Title
在閱讀了與該錯誤相關的 Microsoft 檔案之后,我嘗試將WindowTitle變數改為物件。但沒有成功。
有誰有辦法嗎?
謝謝!
有誰有辦法嗎?
謝謝!
uj5u.com熱心網友回復:
這對我來說是有效的--通過尋找一個打開的視窗,用所傳遞的URL找到IE:
這對我來說是有效的。
Sub tester()
Dim w As Object
Set w = FindingExistingIEByUrl("https://www.google.com"/span>)
如果 不是 w 是 沒有 那么 那么Else
MsgBox "沒有找到IE視窗" "沒有找到IE視窗"End If
End Sub
Function FindingExistingIEByUrl(theUrl)
Dim wAs Object
For Each w In CreateObject("Shell.Application").Windows
'Debug.Print w.locationurl。
如果w.locationurl Like theUrl & "*" Then
Set FindingExistingIEByUrl= w
退出 函式
結束 If
Next w
End Function[/span
Function FindingExistingIEByTitle(theTitle)
Dim w As Object,t As String。
For Each w In CreateObject("Shell.Application") .Windows
t = ""。
On Error Resume Next '忽略錯誤如果沒有Document
t = w.Document.Title
On Error Goto 0
如果 t 喜歡 theTitle 然后
Set FindingExistingIEByTitle = w
退出 函式
結束 If
Next w
End Function[/span
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/320205.html
標籤:
