Hi guys
I'm new here and struggling with online form automation.
My task is to use this website to generate IBAN codes: https://iban-generator.appspot.com/#/make
I have all the necessary data listed in a Database.
Done a lot of research and managed to fill the form, but, even though correct, the data entered in the fields through vba is not recognized as such, yielding the "Invalid Parameters" outcome.
Although if I copy the same exact data manually and repaste it into the same three fields it works just fine.
For testing purposes I'm using Agency ("Agência") = 385, Account ("Conta") = 56723X and ISPB=00000000.
As I said, filling manually works just fine and it yields the IBAN:
Thank you for your time and attention
I'm new here and struggling with online form automation.
My task is to use this website to generate IBAN codes: https://iban-generator.appspot.com/#/make
I have all the necessary data listed in a Database.
Done a lot of research and managed to fill the form, but, even though correct, the data entered in the fields through vba is not recognized as such, yielding the "Invalid Parameters" outcome.
Although if I copy the same exact data manually and repaste it into the same three fields it works just fine.
Code:
Sub IBAN_generator()
Dim wb As Workbook, ws As Worksheet, cpf As String, acc As String, agn As String, ispb As String, iban As Range
Dim ieapp As Object
Set wb = ActiveWorkbook
Set ws = wb.Sheets("Database")
Let calculator = "https://iban-generator.appspot.com/#/make"
Set ieapp = CreateObject("InternetExplorer.Application")
'ieapp.Visible = False
'------------------------------------------------------------------------------------------------------------'
' • Internet Explorer procedures:
With ieapp
.Navigate calculator 'opening the IBAN calculator website
ieapp.Visible = True
Do While ieapp.busy: DoEvents: Loop 'waiting for the website to load
End With
'Inputting data into fields and retrieving IBAN code:
Let i = 4
Do Until ws.Range("B" & i).Value = ""
With ws
Let cpf = .Range("D" & i).Value 'defining cpf number
Let acc = .Range("E" & i).Value 'defining account number
Let agn = .Range("F" & i).Value 'defining agency number
Let ispb = .Range("H" & i).Value 'defining ISPB number
Set iban = .Range("I" & i) 'defining where the IBAN code must be inserted
End With
With ieapp
Set inputCollection = .document.getElementsByTagName("input")
'In the loop bellow the macro inserts data into the necessary fields of the website:
For Each inputElement In inputCollection
Let pholder = inputElement.getAttribute("placeholder")
With inputElement
Select Case pholder
Case Is = "Agência"
.Focus
DoEvents
.Value = agn
Case Is = "Conta"
.Focus
DoEvents
.Value = acc
Case Is = "ISPB"
.Focus
DoEvents
.Value = Format(ispb, "00000000")
End Select
End With
Next inputElement
'Clicking the button to generate the IBAN code
Do While ieapp.busy: DoEvents: Loop 'waiting for the website to load
End With
ieapp.document.all.Item
'Setting the IBAN code for the current row / client:
'[IF I STOP THE MACRO HERE AND MANUALLY COPY AND REPASTE THE SAME DATA IN THE FIELDS IT WORKS JUST FINE]
ieapp.document.getElementById("makeButton").Click
Do While ieapp.busy: DoEvents: Loop 'waiting for the website to load
Let codeiban = ieapp.document.getElementsByClassName("ng-binding")(0).innerHTML
DoEvents
iban.Value = codeiban
i = i + 1
Loop
ieapp.Quit 'closing browser
End Sub
For testing purposes I'm using Agency ("Agência") = 385, Account ("Conta") = 56723X and ISPB=00000000.
As I said, filling manually works just fine and it yields the IBAN:
BR290000000000385000056723XC1
Thank you for your time and attention