VBA Web Form filling works but values not recognized by website

Yamamuen

New Member
Joined
Sep 21, 2018
Messages
2
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.

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
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.

sericom

Well-known Member
Joined
Jan 19, 2006
Messages
915
Try

Code:
.innertext = agn

instead of

Code:
.value = agn

Do the same for Conta and ISPB as well
 

Yamamuen

New Member
Joined
Sep 21, 2018
Messages
2
Thank you sericom! Works like a charm! Struggled with this the whole night, i had no idea inputs with .innertext were any different from .value !
 

Watch MrExcel Video

Forum statistics

Threads
1,130,439
Messages
5,642,126
Members
417,257
Latest member
Sarahbw

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top