Controling a web page - fill in text & submit

C

clueless John

I posted this previously, but got no response. Am I even in the right place
for this question?

I am trying to automate a daily download process that manually requires me
to navigate to a website, select a radio button, fill in two text boxes and
click a submit button. I can get Access to open IExplorer and navigate to
the website by using
Dim ieApp As InternetExplorer
Set ieApp = New InternetExplorer
ieApp.Visible = True
ieApp.Navigate "http://...

After that, I am lost. I've tried to use ieApp.PutProperty with no success.
(I'm either not getting the syntax right, or it just isn't the right method,
???)

Does anyone have a clue for me?
 
T

Tim Ferguson

I am trying to automate a daily download process that manually
requires me to navigate to a website, select a radio button, fill in
two text boxes and click a submit button. I can get Access to open
IExplorer and navigate to the website by using
Dim ieApp As InternetExplorer
Set ieApp = New InternetExplorer
ieApp.Visible = True
ieApp.Navigate "http://...

With a bit of digging around in the form's source code, you should be
able to reconstruct the entire URI of the completed form; then use the
GET or POST method to get the result. You should be able to do this with
a

Set oHttpPost = CreateObject("Microsoft.XMLHTTP")
oHttpPost.Open "GET", c_urlCheckIP, False

or something like that.

Hope it helps


Tim F
 
C

clueless John

I get an invalid procedure call on the line
oHttpPost.Open "GET", c_urlCheckIP, False
Can you explain what it is doing? I don't get any hints form VBA since this
is a generic Object.

As far as digging in the code,
The only access to the web page code is through right-click View Source. I
can identify the names of text boxes, radio buttons, and the submit button
caption.
The submit action appears to be this:
<FORM action="ViewReport.asp" method=Post target=_blank id=form1
name=form1><strong>
It opens another explorer window that churns for a while as
http://...ViewReport.asp, then turns into the report as an excel spreadsheet
with a very long and strange address.
http://...viewrpt.cwr?id=52032&apstoken=...

Can any of this be useful to me?
 
T

Tim Ferguson

I get an invalid procedure call on the line
oHttpPost.Open "GET", c_urlCheckIP, False
Can you explain what it is doing? I don't get any hints form VBA
since this is a generic Object.

Have you tried googling for "Microsoft.XMLHTTP" -- lots of good advice
there?
As far as digging in the code,
The only access to the web page code is through right-click View
Source. I can identify the names of text boxes, radio buttons, and
the submit button caption.

That is all you need. Forms are submitted using a url that is made of the
page address and a ? and the id and value pairs delimited with & and =
characters. This is from memory, but the details are in any basic HTML
book.
The submit action appears to be this:
<FORM action="ViewReport.asp" method=Post target=_blank id=form1
name=form1><strong>

There you go: the uri will look something like

http://somewhere.com/folder/viewreport.asp?name=tim F&age=21&hidden=true

and you need to use the POST method rather than the GET.
Can any of this be useful to me?

All of it! FWIW, this is just what happens behind the scenes with search
toolbars etc.

Hope it helps: if you need any more in depth pointers, then you are
probably better off in an HTML forms group than a database one!

Tim F
 
C

clueless John

I also found another way
Set ieApp = CreateObject("InternetExplorer.Application")

With ieApp
' Make the window visible.
.Visible = True

' Navigate to the input page.
.Navigate "http://.......asp"

' Loop while the page loads.
Do While .Busy: DoEvents: Loop
Do While .ReadyState <> 4: DoEvents: Loop

' Fill in the fields on the form.
' Form(0) refers to the first form on the page.
' the forms collection is Zero based.

With .Document.Forms(0)

' Click the Detail radio button (Summary is (0)).
.rpt(1).Click

' Set the dates.
.stdate.Value = sStart

.enddate.Value = sEnd

' Click Submit to run the report.
.submit

End With
 
Top