Search code examples
vbainternet-explorerexcelframescomexception

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?


Solution

  • 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