Process automation - Excel - VBA

Asked

Viewed 121 times

-1

I am trying to automate a process of my service. However while running the code it says that "A variável do objeto ou a variável do bloco 'With' não foi definida".

What I’d like him to do is:

  • That identified the bar of the site where it is to insert the Cnpj and inside the cell 3 column 1 insert this data.

  • Perform this process but with the captcha data.

    • Doubt: How would it be possible to translate or "cheat" capthca in this situation?
Sub PullData()

    Dim HTMLDOC As HTMLDocument

    Range("B3:D3").ClearContents

    Set ie = CreateObject("internetexplorer.application")

    ie.navigate "https://cvmweb.cvm.gov.br/swb/default.asp?sg_sistema=fundosreg"
    ie.Visible = True

    Do While ie.busy And ie.readyState <> "READYSTATE_COMPLETE"
        DoEvents
    Loop

    HTMLDOC.getElementsByid("txtCNPJNome")(0).Value = Cells(3, 1).Value
    ie.document.getElementsByTagName("numRandom")(0).Value = Cells(3, 2).Value
    ie.document.getElementsByTagName("btnContinuar")(3).Click


    Do While ie.busy And ie.readyState <> "READYSTATE_COMPLETE"
        DoEvents
    Loop

    Cells(4, 2) = ie.document.getElementsByName("td")(0).innertext
    Cells(4, 3) = ie.document.getElementsByTagName("td")(1).innertext
    Cells(4, 4) = ie.document.getElementsByTagName("td")(2).innertext

    ie.Quit

    Range("A3:D3").WrapText = False

    For Each aba In ThisWorkbook.Sheets
        aba.Columns("A:F").AutoFit
    Next

End Sub
```
  • Do you want a recaptcha bypass? See in this one way link. As this captcha you are using is image, maybe with Computer Vision and Deep Learning it is possible to train an algorithm to solve this, but not with VBA. And I don’t know of any that exists for that.

  • In reality it would be contrary to throw the dice in the cell and with this he insert the same in the form tab

1 answer

-1

If I understand your question correctly, you want to take the form information and play in cells.

But right now you’re doing the opposite.

...
    HTMLDOC.getElementsByid("txtCNPJNome")(0).Value = Cells(3, 1).Value
    ie.document.getElementsByTagName("numRandom")(0).Value = Cells(3, 2).Value
...

Cells(3, n).Value has to be on the left side of the assignment signal.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.