PDA

View Full Version : Filling out IE form with data from Excel - and some other stuff :)



jousley
03-03-2011, 05:34 PM
Hey all, this is my first post - and i have been reading some of the stuff people are doing and I never knew Excel had such functionality. I hope you can help or point me in the right direction with this question - I'm not as familiar with VBA but have coding experience. Here's what I want to do:
There is a web form that my company uses a lot to find out if certain users are eligible. It consists of a web form with 4 textboxes to fill out. In my excel spreadsheet I have 4 columns of data - each row containing the information for the 4 textboxes in the webform. I want the VBA to do the following when the macro is run:
1) switch focus to Internet Explorer (which will have the page with the webform already loaded and the cursor in the first text box)
2) enter in the first textbox the value in A1
3) tab
4) enter in the 2nd textbox the value in A2
5) tab
6) enter in the 3rd textbox the value of A3
7) tab
8) enter in the 4th textbox the value of A4
9) press submit on the webform
10) wait 5 seconds (for the results to load on the webform)
11) print (file, print) the results in IE
12) hit the back button (to go back to webform)
13) enter the first textbox the value in B1

and on and on until there are no longer values in the rows in the excel spreadsheet.

Is this even possible to do using VBA? and if so, please head me in the right direction as this will certainly solve a lot of problems for me and my departments. I really appreciate your advice and knowledge. thanks a million

J.

Charlize
03-04-2011, 01:57 AM
what's the url ?

jousley
03-04-2011, 12:37 PM
you have to log into the site before you get to the form page so you wouldn't be able to see it yourself. What information do you need about the form. Perhaps I could identify that and we could move forward.,

thanks again
J.

Kenneth Hobs
03-04-2011, 01:25 PM
Since we can't test it, it is hard to help. The best way to get help in that case is to provide screen prints for each part and the Page Source. Some sites are secure where only SendKeys() solutions would work. We can only see that in the Page Source. In Firefox, click the View button to get a website's Page Source text.

_angel
07-20-2012, 02:15 PM
Hey, I also have same problem here. I don't know anything about vba but somehow I managed to come up with a macro (by reading forums) to fill out a web form from excel.
Here's the code which successfully open up the browser, go to website, fill out the form and submit. I want to do this for the remaining rows. (Each row = 1 submission) How can I do this? Also is it possible to open the website in a tab instead of another window when the macro runs?

Sub Fill_Form()
Set IE = CreateObject("InternetExplorer.Application")
With IE
.Visible = True
.navigate URL:="THEURL"
Do Until .readystate = 4
DoEvents
Loop
Set mytextfield1 = .document.all.Item("pin[title]")
mytextfield1.Value = Sheets("Sheet1").Range("b3").Value
Set mytextfield2 = .document.all.Item("pin[merchant]")
mytextfield2.Value = Sheets("Sheet1").Range("c3").Value
Set mytextfield3 = .document.all.Item("pin[offer_type]")
mytextfield3.Value = "coupon"
Set mytextfield4 = .document.all.Item("pin[code]")
mytextfield4.Value = Sheets("Sheet1").Range("d3").Value
Set CreatePin = .document.all.Item("commit")
CreatePin.Click

End With
End Sub


I know this site is over a year ago.. I hope anyone out there could help me.
Thank you in advance!

--
angel

_angel
07-20-2012, 02:26 PM
Since we can't test it, it is hard to help. The best way to get help in that case is to provide screen prints for each part and the Page Source. Some sites are secure where only SendKeys() solutions would work. We can only see that in the Page Source. In Firefox, click the View button to get a website's Page Source text.

I'm hoping that you could help me out..
Thank you!

Charlize
07-24-2012, 11:49 PM
Maybe change
Set IE = CreateObject("InternetExplorer.Application")
to
Set IE = GetObject("InternetExplorer.Application")
No errorchecking, so better be sure that Internet Explorer is running.

If you want to loop the rows in a worksheet, you have to build a loop around the filling in of the internet form.

Charlize