Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

auto fill webform and submit and loop from xls sheet

Status
Not open for further replies.
Aug 10, 2016
5
US
I have been working on this for a bit here is what I have any help would be greatly apprieciated.

Sub submitFeedback3()
Application.ScreenUpdating = False

Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = True
IE.Navigate "
Application.StatusBar = "Submitting"
' Wait while IE loading...
While IE.Busy
DoEvents
Wend
' **********************************************************************
IE.Document.All("fname").Value = ThisWorkbook.Sheets("Leads").Range("a1:a1000")
IE.Document.All("email").Value = ThisWorkbook.Sheets("Leads").Range("b1:b1000")
IE.Document.getElementById onclick = "sendForm"
'**********************************************************************
Application.StatusBar = "Form Submitted"
IE.Quit
Set IE = Nothing

Application.ScreenUpdating = True
End Sub

Private Sub delay(seconds As Long)
Dim endTime As Date
endTime = DateAdd("s", seconds, Now())
Do While Now() < endTime
DoEvents
Loop
End Sub
 
Steve,

Please be sure to delete your other duplicate thread.

Code:
'
    Dim r As Range
    
    For Each r In ThisWorkbook.Sheets("Leads").Range("a1:a1000")
        IE.Document.All("fname").Value = r.Value
        IE.Document.All("email").Value = r.Offset(0, 1).Value
        IE.Document.getElementById onclick = "sendForm"
    Next

Just curious...
Why don't you have HEADINGS for your table? faq68-5184

Furthermore, If you have Excel version 2007 or greater, the Structured Table feature is really quite remarkable. Let's say that your headings are User Name & eMail Address. With a Structured Table...
Code:
'
    Dim r As Range
    
    For Each r In [Table1[[b]User Name[/b]]]
        IE.Document.All("fname").Value = r.Value
        IE.Document.All("email").Value = Intersect(r.EntireRow, [Table1[[b]eMail Address[/b]]]).Value
        IE.Document.getElementById onclick = "sendForm"
    Next

Skip,

[glasses]Just traded in my OLD subtlety...
for a NUance![tongue]
 
Thanks it worked all accept the submit part I have something wrong still. To answer your question I'm pretty green to programing just trying to learn...
 
Skip How do I get this submit and reload the page When I run it I see all the data flying through but its not being submitted Thanks again for your help.
 
I know nothing about IE properties and methods.

But something like this might work. I forgot to add it originally...
Code:
'
    Dim r As Range
    
    For Each r In ThisWorkbook.Sheets("Leads").Range("a1:a1000")
        IE.Document.All("fname").Value = r.Value
        IE.Document.All("email").Value = r.Offset(0, 1).Value
        IE.Document.getElementById onclick = "sendForm"[b]
        While IE.Busy
            DoEvents
        Wend[/b]
    Next

Skip,

[glasses]Just traded in my OLD subtlety...
for a NUance![tongue]
 
That might work but this line doesn't fail but it doesn't submit or it might have worked.
IE.Document.getElementById onclick = "sendForm"
is having issues submitting. I think I'm closer though.. Do you know of an IE.form code?


 
Skip,

Thank You for all your help i do appreciate it. I did finally get the code to work and wanted to share it with you. not sure if there is a better way or not but this works.

Sub submitFeedback3()
Application.ScreenUpdating = False

Set IE = CreateObject("InternetExplorer.Application")
IE.Navigate " IE.Visible = True

Application.StatusBar = "Submitting"
' Wait while IE loading...
While IE.Busy
DoEvents
Wend

Dim r As Range

For Each r In ThisWorkbook.Sheets("Leads").Range("a1:a1000")
IE.Document.All("fname").Value = r.Value
IE.Document.All("email").Value = r.Offset(0, 1).Value
IE.Document.getElementById("formbutton").onclick

While IE.Busy
DoEvents
Wend
IE.Quit
Application.StatusBar = "Form Submitted"
Set IE = CreateObject("InternetExplorer.Application")
IE.Navigate " IE.Visible = True

Next
End Sub
 
Glad you got it working and posted your solution for the benefit of others.

Skip,

[glasses]Just traded in my OLD subtlety...
for a NUance![tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top