ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Excel Import by Webquery (https://www.excelbanter.com/excel-programming/388588-excel-import-webquery.html)

safflenow

Excel Import by Webquery
 
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

Dave Miller

Excel Import by Webquery
 
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


safflenow

Excel Import by Webquery
 
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!

"Dave Miller" wrote:

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




All times are GMT +1. The time now is 05:23 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com