shahin
Active Member
I've created a macro which is able to click few links on a webpage to unhide a search-box and after filling the search-box with required number, when I click on the go button to display the data, I can successfully do that as well. However, the problem is the required data get displayed in a new tab. This is a brand new problem to me and I can't deal with it anyway. However, the only hint I got is that I need to make my script focus on that new window. I don't know how to do that. I've already set variable to grab the data but I'm getting every time the same error when my script hits the "Debug.print" line and the error is "Application-defined or object-defined error". How can I reach the data by focusing on the new tab? Thanks in advance.
Here is the script:
I'm uploading an Image to show you which field/fields I'm after. The image is taken from the new window.
Here is the script:
Code:
Sub Grab_Data()
Dim post As Object
With CreateObject("InternetExplorer.Application")
.Visible = True
.navigate "http://www.trf5.jus.br/cp/"
While .Busy = True Or .readyState < 4: DoEvents: Wend
.document.getElementById("tipo_xmlrpvprec").Click
.document.getElementById("tipo_xmlprec").Click
.document.getElementById("filtroRPV_Precatorios").Value = "160340"
.document.getElementById("submitConsulta").Click
''after performing the click a new window opens up here
''tried waiting here
Do
Set post = .document.getElementsByClassName("linkar")
DoEvents
Loop While post Is Nothing
''tried waiting here as well
Debug.Print post(0).innerText
End With
End Sub
I'm uploading an Image to show you which field/fields I'm after. The image is taken from the new window.