简体   繁体   中英

Method 'frames' of object 'JScriptTypeInfo' failed

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?

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM