繁体   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