VBA code to Enter Data to Webpage or IE

enter data to webpage
Sommario

VBA Enter Data into webpage – IE Automation using VBA GetElementByID function

Che cosa è:

If you are trying to do ie automation or trying to enter data to webpage using VBA then this post if for you. We will show the step by step instructions on how to enter/fill data in ie using VBA.

Enter Data To WebpagePin

Perché è:

This is very helpful when you want to enter or fill multiple fields in a webpage regularly. Or if you want to login to website in a single click without using the browser’s default Remember My Password option etc.

Come to enter data to webpage using vba




In this example we are using Excel VBA for IE Automation however you can use any VBA supported platform.

Passo 1: Open the Excel workbook and got to VBA code builder (Alt + F11) and Open a New Module.

Enter Data To Webpage

Passo 2: Copy and Paste the below code in it.

Sottomarino privato wpieautologin()

Fioco ie COME SHDocVw.InternetExplorer

Set ie = Nuovo SHDocVw.InternetExplorer

ie.Visible = VERO 

ie.Navigate “https://www.askeygeek.com/wp-admin” ‘we are trying to login to askeygeek.com admin page

Do

DoEvents

Loop Until ie.readystate = 4

‘ie READYSTATE has 5 different status codes, here we are using status 4:

‘Uninitialized = 0

‘Loading = 1

‘Loaded = 2

‘Interactive =3

‘Complete = 4 

Call ie.Document.GetElementByID(“user_login”).SetAttribute(“value”, “testUser”)

Call ie.Document.GetElementByID(“user_pass”).SetAttribute(“value”, “testPass12345”)

 ‘to find the “<input……/>” tag hyper link and to click the button

Set AllInputs = ie.Document.getelementsbytagname(“input”) ‘you can use any tagname as you wish

    Per Each hyper_link In AllInputs

        Se hyper_link.Name = “wp-submit” Allora ‘you can use .name, .id etc

            hyper_link.Click

            Exit Per

        End Se

    Prossimo

Do

DoEvents

Loop Until ie.readystate = 3

Do

DoEvents

Loop Until ie.readystate = 4

End Sub

Passo 3: Fare clic sul pulsante Esegui o su F5 (inoltre è possibile inserire un pulsante/forma nel foglio excel, quindi fare clic con il pulsante destro del mouse e assegnare questa macro per l'esecuzione ogni volta).

Enter Data To Webpage

Notes 1: Make sure ‘Microsoft Internet Controls’ is enabled from the Tools – References.

Ie AutomationPin

Notes 2: Right click the webpage to and click View source to find the GetElement values

GetelementsbytagPin



Picture of Anson Antony
Anson Antonio
Anson è un autore collaboratore e fondatore di www.askeygeek.com. Imparare qualcosa di nuovo è sempre stata la sua passione, ASKEYGEEK.com è il risultato della sua passione per la tecnologia e il business. Ha un decennio di esperienza versatile in Business Process Outsourcing, Finanza e Contabilità, Informatica, Eccellenza Operativa e Business Intelligence. Durante il mandato, ha lavorato per organizzazioni come Genpact, Hewlett Packard, M*Modal e Capgemini in vari ruoli e responsabilità. Al di fuori degli affari e della tecnologia, è un appassionato di cinema che trascorre ore insieme guardando e imparando il cinema e anche un regista!

7 risposte

  1. hi team, i need to fill the data in Browser tab, which is already opened and navigated to the exact page, where i need to fill my data, please provide the VBA code to deal with this session.

  2. Can you help me here?
    There is no id or value set in the following lines of code, how do I insert say into the “lastnameFilter” or “firstnameFilter”?

    Learner’s ID

    Nome di battesimo

    Family Name

    Search

    Grazie

Lascia un commento

Il tuo indirizzo email non sarà pubblicato. I campi obbligatori sono contrassegnati *

Congratulazioni!
L'hai fatta,
Non chiudere!

Alzati 60.000 Crediti per personaggi UberTTS gratis!!!

Questo popup non mostrerà sta a te Ancora!!!

UberTTS
4
Share to...