Our business uses a browser-based program for operations. I'm automating a solution to navigate through this site, and retrieve some data at the end.
The site itself uses regular frames very heavily. However, at the very end of my process, it populates my data not into a frame, but an iFrame. There's also very extensive javascript throughout the site, making things muddy.
Grabbing the iFrame's src URL and opening in a new browser errors out the page (i.e. the page displays error text instead of the content).
My question:
How can I grab the text out of an iFrame through VBA?
What I've tried so far (feel free to skip):
Target a specific iFrame in a specific frame, and grab innerHTML
With ie.document.frames(myFrameNum).document.getElementsByTagName("iframe")(1).document.body
stringResult = .innerHTML
Target a specific iFrame by ID in a specific frame, and grab innerHTML
Dim iFrm As HTMLIFrame
Set iFrm = ie.document.frames(myFrameNum).document.getElementByID("iFrameID")
Debug.Print iFrm.document.body.innerText
Find any instances of iFrames, and grab them (No results - perhaps because the iframe is embeded in a frame?)
Dim iFrm As HTMLIFrame
Dim doc As HTMLDocument
For iterator = 0 To ie.document.all.Length - 1
If TypeName(ie.document.all(iterator)) = "HTMLIFrame" Then
Set iFrm = ie.document.all(iterator)
Set doc = iFrm.document
Debug.Print & doc.body.outerHTML
End If
Next