I have found this code and adapted to my needs and it works:
Sub Automate_IE_Enter_Data()
Dim i As Long
Dim URL As String
Dim IE As Object
Dim objElement As Object
Dim objCollection As Object
Dim HWNDSrc As Long
Dim fso As Scripting.FileSystemObject
Dim tsTxtFile As Object
Set fso = New FileSystemObject
Set fso = New Scripting.FileSystemObject
Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = True
URL = "Enter the url you needs here"
IE.Navigate URL
Do While IE.ReadyState = 4: DoEvents: Loop
HWNDSrc = IE.HWND
SetForegroundWindow HWNDSrc
For Each itm In IE.document.all
If itm = "[object HTMLInputElement]" Then
itm.Value = "Title of the IE Window"
itm.Focus
Application.SendKeys "^s", True
Application.Wait (Now + TimeValue("0:00:2"))
Application.SendKeys "D:\web_page.txt", True
Application.Wait (Now + TimeValue("0:00:2"))
Application.SendKeys "{TAB}", True
Application.Wait (Now + TimeValue("0:00:2"))
Application.SendKeys "{DOWN}{DOWN}{DOWN}{DOWN}", True
Application.Wait (Now + TimeValue("0:00:2"))
Application.SendKeys "%E", True
Application.Wait (Now + TimeValue("0:00:5"))
Application.SendKeys "%O", True
Application.Wait (Now + TimeValue("0:00:5"))
GoTo endmacro
End If
Next
endmacro:
Set IE = Nothing
Set objElement = Nothing
Set objCollection = Nothing
End Sub
Bookmarks