rrhandle8
asked on
Using VBA to fill a web form not working
I have spent two days on this. Time to ask for help. I am placing orders on Overstock. The following code gives different errors when I try to select from two drop-down boxes.
I item is live, so you can try it on your end.
I item is live, so you can try it on your end.
Enum READYSTATE
READYSTATE_UNINITIALIZED = 0
READYSTATE_LOADING = 1
READYSTATE_LOADED = 2
READYSTATE_INTERACTIVE = 3
READYSTATE_COMPLETE = 4
End Enum
Sub Connect()
'to refer to the running copy of Internet Explorer
Dim ie As InternetExplorer
'to refer to the HTML document returned
Dim html As HTMLDocument
'open Internet Explorer in memory, and go to website
Set ie = New InternetExplorer
ie.Visible = True
ie.navigate "http://www.overstock.com/Bedding-Bath/Aloha-Girls-Multicolor-Printed-Cotton-Pieced-Quilt-Set/5036546/product.html?keywords=12915080&searchtype=Header"
'Wait until IE is done loading page
Do While ie.READYSTATE <> READYSTATE_COMPLETE
DoEvents
Loop
varTemp = Split("12915080-6882393", "-")
ItemNum = varTemp(0)
OptionNum = varTemp(1)
ProductNum = "5036546"
ElementID = "addid" & ProductNum
ie.document.getElementById(ElementID).Value = OptionNum
ElementID = "addqty" & ProductNum
ie.document.getElementById(ElementID).Value = 4
Stop
ie.navigate "http://www.yahoo.com"
Do While ie.Busy: DoEvents: Loop
Do Until ie.READYSTATE = READYSTATE_COMPLETE: DoEvents: Loop
ie.Quit
Set ie = Nothing
End Sub
ASKER
Glenn,
I tried your code. It has the same problem I had before: The qty does not get set. Put a stop right before the yahoo link.
I tried your code. It has the same problem I had before: The qty does not get set. Put a stop right before the yahoo link.
There must be another method that will allow the quantity field to update. If one manually selects the same option ("Twin"), the quantity field updates dynamically. In the code, it does not. However, I'm at a loss as to what method you can use to make this happen.
ASKER
Me too, Glenn. This is a tough one.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Open in new window
-Glenn