Sub automaticformfilling()
Dim ie As InternetExplorer
Dim doc As MSHTML.HTMLDocument
Set ie = CreateObject("internetexplorer.application")
With ie
.Visible = True
.navigate "xxxxxx"
'Wait for loading
Do While .Busy
DoEvents
Loop
Do While .readyState <> 4
DoEvents
Loop
End With
Set doc = ie.document
Set fname = doc.getElementById("j_username")
fname.Value = "xxxx"
Set lastName = doc.getElementById("j_password")
lastName.Value = "xxxx"
doc.getElementsByName("btn_submit")(0).Click
'Set doc = ie.document
'Set invdate = doc.getElementsByClassName("GHNF1GMDEI")
'invdate.Value = "25"
Set refname = doc.getElementsByName("GHNF1GMDGM")
'.doc.getElementsByClassName ("GHNF1GMDGM")
refname.Value = "923456"