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