VBA code to Enter Data to Webpage or IE

enter data to webpage
İçindekiler

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

Ne bu mu:

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

Neden bu mu:

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.

Nasıl 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.

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

Enter Data To Webpage

Adım 2: Copy and Paste the below code in it.

Private Sub wpieautologin()

Loş ie Gibi SHDocVw.InternetExplorer

Set ie = New SHDocVw.InternetExplorer

ie.Visible = Doğru 

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

    İçin Each hyper_link İçinde AllInputs

        Eğer hyper_link.Name = “wp-submit” O zaman ‘you can use .name, .id etc

            hyper_link.Click

            Exit İçin

        End Eğer

    Sonraki

Do

DoEvents

Loop Until ie.readystate = 3

Do

DoEvents

Loop Until ie.readystate = 4

End Alt

Aşama 3: Click the Run button or F5.(Also you can insert a button/shape in excel sheet then right click and assign this macro to run every time.)

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 Antony
Anson katkıda bulunan bir yazar ve kurucudur. www.askeygeek.com. Yeni bir şeyler öğrenmek her zaman onun tutkusu olmuştur, ASKEYGEEK.com teknoloji ve iş tutkusunun bir sonucudur. İş Süreci Dış Kaynak Kullanımı, Finans ve Muhasebe, Bilgi Teknolojisi, Operasyonel Mükemmellik ve İş Zekası alanlarında on yıllık çok yönlü bir deneyime sahiptir. Görev süresi boyunca Genpact, Hewlett Packard, M*Modal ve Capgemini gibi kuruluşlarda çeşitli rol ve sorumluluklarda çalıştı. İş ve teknoloji dışında, birlikte saatlerce Sinema ve Film Yapımcısı izleyerek ve öğrenen bir film tutkunu!

7 yanıt

  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

    İlk adı

    Family Name

    Search

    Teşekkürler

Bir yanıt yazın

E-posta adresiniz yayınlanmayacak. Gerekli alanlar * ile işaretlenmişlerdir

Tebrikler!
Başardın,
Kapatmayın!

Yukarı Çık 60.000 Ücretsiz UberTTS Karakter Kredisi!!!

Bu açılır pencere gösterilmeyecek size kalmış Tekrar!!!

UberTTS
4
Share to...