Fill Web Form with User Form Data

How to fill web form with User Form data automatically with VBA. To log into a website we can create a similar user form and then fill the web form via the user form using VBA. Watch the video:

Watch this video on YouTube.

user form
Fill web form with user form data using VBA

Here’s the complete VBA code to automate the process of filling web forms using data of user forms via Excel VBA:

Private Sub CommandButton2_Click()

Url = “”

Set ie = CreateObject(“internetexplorer.application”)
ie.Visible = True
ie.navigate Url

Dim HTMLDoc As HTMLDocument

Dim MyHTML_Element As IHTMLElement
Loop Until ie.readyState = READYSTATE_COMPLETE

Set HTMLDoc = ie.document

HTMLDoc.all.companyid.Value = TextBox1.Text
HTMLDoc.all.UserName.Value = TextBox2.Text
HTMLDoc.all.Password.Value = TextBox3.Text

For Each MyHTML_Element In HTMLDoc.getElementsByTagName(“input”)
If MyHTML_Element.Type = “image” Then
MyHTML_Element.Click: Exit For
End If

End Sub

Published by

Dinesh Kumar Takyar

Welcome to! My aim is to help you learn MS Excel including VBA. I always felt that a good way to learn something was to find solutions to problems in that domain. That is why I share these Excel videos with you. Mostly these are questions asked during my corporate training sessions. I've been training individuals and companies in computers since 1991. I did my B. Sc. (Vordiplom), M. Sc. (Diplom) and Ph.D. (Dr. rer. nat.) from Hamburg, Germany. The best thing about solving some of my visitor's questions is that I also gain new insights. For more Excel VBA solutions you may like to visit my YouTube channel: For a structured Excel VBA training course online you can visit:

Leave a Reply

Your email address will not be published. Required fields are marked *