I have two codes for an automatic form fill. The first one is for the login and the second one for the form. If I only knew how to put them together instead of having two different buttons and two browser pages. Both codes work with no problem when put in different modules. I am new at this so if some could help me it would mean a lot.
[CODE]
CODE 1:
Dim HTMLDoc As HTMLDocument
Dim MyBrowser As InternetExplorer
Sub EW()
Dim MyHTML_Element As IHTMLElement
Dim MyURL As String
MyURL = "link"
Set MyBrowser = New InternetExplorer
MyBrowser.Silent = True
MyBrowser.navigate MyURL
MyBrowser.Visible = True
Do
Loop Until MyBrowser.readyState = READYSTATE_COMPLETE
Set HTMLDoc = MyBrowser.document
HTMLDoc.all.UserName.Value = "userdsfkjgh" 'Enter your email id here
HTMLDoc.all.Password.Value = "dstzdsrtz" 'Enter your password here
For Each MyHTML_Element In HTMLDoc.getElementsByTagName("input")
If MyHTML_Element.Type = "submit" Then MyHTML_Element.Click: Exit For
Next
End Sub
CODE 2:
Option Explicit
Sub EW()
Dim IE As InternetExplorer
Set IE = New InternetExplorer
IE.Visible = True
IE.navigate "sdfghdghf"
Do While IE.readyState <> READYSTATE_COMPLETE
DoEvents
Loop
Dim doc As HTMLDocument
Set doc = IE.document
doc.getElementById("_data").Value = "05.02.2021"
doc.getElementById("_data2").Value = "10.02.2021"
doc.getElementById("data3").Value = "dfg"
End Sub