I need in Excel (vba) to make a macro or robot to enter some data in a web page taking as values a list of data (cedula and date) that I have in an Excel sheet, those parameters I can already pass to the form with this element "IE.Document.getElementById", but when I try to click the button that appears to be able to complete the operation I want, I see that the button as such does not have a variable id or the name to be able to click from Excel.
I leave the webpage I'm trying to access:
I still get an error, I opened a new module in Excel vba and run the program but it gives me a syntax error in the line that I highlight with asterisks:
Sub CARGAR_DATOS_WEB()
Dim IE As Object
Dim allelements As Object
Application.ScreenUpdating = False
'Creamos objeto internet explorer
Set IE = CreateObject("InternetExplorer.Application")
'abrimos web
IE.navigate "https://aplicaciones.msp.gob.ec/coresalud/app.php/publico/rpis/afiliacion/consulta"
'esperamos a que se carguen todos los elementos
Do Until IE.ReadyState = 4
DoEvents
Loop
'si necesitamos más tiempo lo podemos configurar aquí
Application.Wait (Now + TimeValue("0:00:1000"))
'localizamos el ID que hace referencia al cuadro de búsqueda
'esto lo hacemos buscando en el código HTML de la página web
'e igualamos el valor de la celda para realizar la búsqueda
IE.document.getElementById("identificacion").Value = "0960413078"
IE.document.getElementById("fechaconsulta").Value = "10-06-2017"
'también buscamos ID correspondiente al botón para buscar el valor
***IE.document.getElementsByClassName("btn-primary")[0].click();***
'hacemos visible la web.
IE.Visible = True
Set IE = Nothing
Application.ScreenUpdating = True
End Sub