Excel Import by Webquery

S

safflenow

I am currently running a web query that requires the macro to make a few
adjustments before submitting a form on a web page. All works well until I
try to change a radio button.

With IE
.Visible = True
.Navigate "http://www.freddiemac.com/mbs/cgi-bin/newdeal.pl?"

' Loop until the page is fully loaded
Do Until Not .Busy
DoEvents
Loop
Application.Wait (Now() + TimeValue("0:00:02"))

' Make the desired selections on the web page and click the submit Button
Set ipf = IE.document.all.Item("RemicNum")
ipf.Value = i
Set ipf = IE.document.all.Item("SET")
ipf.Value = "CHECKED"

IE.document.Forms(0).submit

Sadly, the code does not work. Does anyone know how I can change the button
via the web query?

Regards
 
D

Dave Miller

Try this:

Regards,

David Miller

Sub DOIT()
Dim IE As Object
Set IE = CreateObject("InternetExplorer.Application")
With IE
.Visible = True
.Navigate "http://www.freddiemac.com/mbs/cgi-bin/newdeal.pl?"

Do Until .readystate = 4
DoEvents
Loop

With .Document
Set ipf = .all.Item("RemicNum")
ipf.Value = i

With .forms(0)
For i = 0 To .Length - 1
With .Item(i)
If .Value = "SET" Then
.Checked = True
End If
End With
Next
.submit
End With
End With
End With
Set ipf = Nothing
Set IE = Nothing
End Sub
 
S

safflenow

That worked perfectly! You have saved me hours of frustration as I would
never have thought of going through all the forms. Thanks a million!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top