PDA

View Full Version : Fill in form on website and submitting multiple values in new tabs



vojokolenic
04-24-2015, 05:25 AM
Hi,

I am new to programming, but I know some of the basics. I need Excel 2007 macro that will fill in one field on a specific website with values from a selection in my sheet and click submit button. And I want it to be able to open separate tabs in the same window for each value in my selection.
I am checking emails from a column in my sheet to see whether or not it has right domain and username. I have to do everything manually, so I wanted to automate this process, to select let's say 3 emails, and check them all at the same time in separate tabs of the same window in IE7.

Here is what I made so far.


Sub FillInternetForm()


Dim IE As Object
On Error Resume Next
For Each c In Selection
Set IE = CreateObject("InternetExplorer.Application")
IE.Navigate "myURL"
IE.Visible = True
While IE.busy
DoEvents
Wend

IE.Document.All("email").Value = c
Set form = IE.Document.Body.GetElementsByTagName("form")(0)
Set Button = form.GetElementsByTagName("input")(2)
Button.Click

Next c

End Sub

It does what I need, but there are couple of problems that occur.
First, it opens separate windows for each check.
Second, it usually fills in only two emails from the selection. Sometimes it fills 3 emails, but for the last one nothing happens - it doesn't click button.

I would appreciate a lot if someone could help me with my code.

mancubus
04-27-2015, 07:58 AM
maybe...



Sub FillInternetForm()

Dim c As Range

On Error Resume Next

For Each c In Selection
With CreateObject("InternetExplorer.Application")
.Visible = True
.Navigate "myURL"
Do While .busy: DoEvents: Loop
Do While .ReadyState <> 4: DoEvents: Loop
.Document.All("email").Value = c
Set form = .Document.Body.GetElementsByTagName("form")(0)
Set Button = form.GetElementsByTagName("input")(2)
Button.Click
Do While .busy: DoEvents: Loop
Do While .ReadyState <> 4: DoEvents: Loop
.Quit
End With
Next c

End Sub