簡體   English   中英

對象“ JScriptTypeInfo”的方法“框架”失敗

[英]Method 'frames' of object 'JScriptTypeInfo' failed

我正在通過excel VBA進行Internet Explorer 9的自動化,當我到達下面的最后一行時,它將引發錯誤:

Set ie = CreateObject("InternetExplorer.Application")
ie.Visible = True
ie.navigate "https://example.com/Main.asp"

'delay till readystate is complete

Set doc = ie.document
Set doc1 = doc.frames(2).document 'here comes the error

誰能幫忙嗎?

我遇到了同樣的問題,並且解決了

這將適用於IE 10+

設置doc = ie.document.frames

設置doc1 = doc.frames(2)

對於腳本元素,不再支持readyState。 從Internet Explorer 11開始,使用onload

IE 11具有訪問屬性的不同方法

遷移到IE11后,我在一些Excel VBA代碼中遇到了相同的問題。 這是我必須解決的問題:

舊代碼在IE8中有效,但在IE11中引發錯誤

Set objCollection = IE.Document.frames(0).Document.getElementsByTagName("span")

在IE11中有效的新代碼(我必須在工具/引用下添加對Microsoft HTML對象庫的引用)

Dim htmlDoc As MSHTML.HTMLDocument
Dim htmlWindow As MSHTML.HTMLWindow2
Set htmlDoc = IE.Document
Set htmlWindow = htmlDoc.frames(0)
Set objCollection = htmlWindow.Document.getElementsByTagName("span")

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM