Goto Error Handling Does not work in loop

1

I have an application running in VBA, in it I have an error handling that works perfectly the first time the action goes through it, but it is inside a For Each loop and the second time it simply ignores the treatment, I do not know if I'm forgetting some detail or if it just does not run when looped twice or something, someone knows the reason for this. Below is part of the code that is giving this error.

On Error GoTo Erro
namePdf = doc3.Document.all.tags("font")(8).innerText

For Each exibirDoc In doc2.Document.all.tags("img")

    ver = exibirDoc.src

    If ver = "https://pan.interfile.com.br/imagens/FileSearch.gif" Then
         exibirDoc.Click
         Exit For
    End If

Next
    
asked by anonymous 23.11.2017 / 14:05

1 answer

0

I found a way to solve my problem, I threw the snippet of code that locates the error in a separate Sub, so I call that sub in the code every time the application passes through it, at that time the program is redirected to that sub and when it finishes it goes back to the sub that is before and performs the loop, that way GoTo always works on all the turns of the For Each. Thanks to all who responded, as I said, this is a way to work with GoTo more than once in the algorithm. Of course using this method is not well seen, but it was the only way I found working on my problem.

    
24.11.2017 / 17:56