Hi All,
I'm hoping you could help me with an issue I've been having while trying to search for values from a label array on a webpage. What I'm trying to do is find a value from a label on a userform on a webpage and then have it display the results back on the userform. The loop seems to work great the first time however, when it goes through the loop the second time it can never find the 2nd value. I have searched for these values individually outside the loop and it finds them with no issue, I'm not sure why it can't find them from within the loop. Whenever I step through the code (F8) the "findText" line is returning a zero and then I get a runtime 5 error "invalide procedure call or argument" on the next line (txt = Mid(iedoc.body.innerHTML, findText). I am a programming novice so please bare with me if I need a more in depth explanation. Below is my code for running through the loop on the webpage. I have to block out the URL's for security reasons.
Value1 = Left(lblarray(I).Caption, 3)
Value2 = Left(lblarray(I).Caption, 2)
For I = LBound(lblarray) To UBound(lblarray)
'Find if rule/Calc or data field
If Value1 = "RU_" Or Value2 = "C_" Then
ie.navigate "I can't include this"
Do Until ie.readyState = READYSTATE_COMPLETE
Loop
Else
ie.navigate "I can't include this"
Do Until ie.readyState = READYSTATE_COMPLETE
Loop
End If
ToFind = lblarray(I).Caption
tof = Len(ToFind)
findText = InStr(1, iedoc.body.innerHTML, ToFind, vbTextCompare)
txt = Mid(iedoc.body.innerHTML, findText)
If findText > 0 Then
Dim x As Long, j As Long, msg As String
If Value1 = "RU_" Then
x = 7
Else
x = 4
End If
For j = 0 To x - 1
lblarray(I).Caption = Split(txt)(j) & " "
Next j
Else
MsgBox "The text dosen't exist"
End If
Next I
End If
Thank you to everyone who takes the time to read through this!!!
-Joe
I'm hoping you could help me with an issue I've been having while trying to search for values from a label array on a webpage. What I'm trying to do is find a value from a label on a userform on a webpage and then have it display the results back on the userform. The loop seems to work great the first time however, when it goes through the loop the second time it can never find the 2nd value. I have searched for these values individually outside the loop and it finds them with no issue, I'm not sure why it can't find them from within the loop. Whenever I step through the code (F8) the "findText" line is returning a zero and then I get a runtime 5 error "invalide procedure call or argument" on the next line (txt = Mid(iedoc.body.innerHTML, findText). I am a programming novice so please bare with me if I need a more in depth explanation. Below is my code for running through the loop on the webpage. I have to block out the URL's for security reasons.
Value1 = Left(lblarray(I).Caption, 3)
Value2 = Left(lblarray(I).Caption, 2)
For I = LBound(lblarray) To UBound(lblarray)
'Find if rule/Calc or data field
If Value1 = "RU_" Or Value2 = "C_" Then
ie.navigate "I can't include this"
Do Until ie.readyState = READYSTATE_COMPLETE
Loop
Else
ie.navigate "I can't include this"
Do Until ie.readyState = READYSTATE_COMPLETE
Loop
End If
ToFind = lblarray(I).Caption
tof = Len(ToFind)
findText = InStr(1, iedoc.body.innerHTML, ToFind, vbTextCompare)
txt = Mid(iedoc.body.innerHTML, findText)
If findText > 0 Then
Dim x As Long, j As Long, msg As String
If Value1 = "RU_" Then
x = 7
Else
x = 4
End If
For j = 0 To x - 1
lblarray(I).Caption = Split(txt)(j) & " "
Next j
Else
MsgBox "The text dosen't exist"
End If
Next I
End If
Thank you to everyone who takes the time to read through this!!!
-Joe