Method 'frames' of object 'JScriptTypeInfo' failed

喜欢而已 提交于 2019-12-10 11:48:34

问题


I am working on automation of internet explorer 9 through excel VBA, it throws an error when I reach on the last line below:

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

can anyone please help?


回答1:


i Have face the same issue and it got resolved

This will work for IE 10+

Set doc = ie.document.frames

Set doc1 = doc.frames(2)

For the script element, readyState is no longer supported. Starting with Internet Explorer 11, use onload

IE 11 has different ways to access attributes




回答2:


I had the same problem with some Excel VBA code after migrating to IE11. This is what I had to do to fix it:

old code which worked in IE8 but threw the error in IE11

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

new code which works in IE11 (I had to add a reference to Microsoft HTML Object Library under tools/references)

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")


来源:https://stackoverflow.com/questions/26347286/method-frames-of-object-jscripttypeinfo-failed

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!