Writing values to Web Forms

  • Thread starter Thread starter Brian Lopez
  • Start date Start date
B

Brian Lopez

All:

Is it possible to write values, using VB, to a web form in
IE?

Thanks,
Brian A Lopez
 
I guess my attempt is extremely complicated.
In the login screen example, I would like to read the text
to the left of the combobox and the enter the appropriate
values before I would click on signon.

Is this even possible, does IE cooperate with VB?
 
Hi Brian,

Yes, you can do this. If the text is within a named HTML element (if the
element has id="foo" or name="foo" in the tag), it is easier to get via the
GetElementByID or GetElementByName, which are methods of the Document or
Body object, I think. If not, you'll have to search the whole body for it
using Document.Body.InnerText or InnerHTML to get the text or source of the
document body.

So the process would go: 1) navigate to the signon page, 2) read the value
you need using one of the methods above, 3) post the form data to the signon
processing page (the action attribute of the form element), then hopefully
you'll be logged in.

If you continue to have problems, please post the URL, and I'd be happy to
help you further.
 
I'm working on a similar problem and having some difficulty.
Two things:

First when I execute this line of code having previously created the
IE object and made it visible

oInt.Navigate sURL, 0, " self", bytePost, sHeader

I get a second IE window. I've played with " self" trying "_SELF",
"_self", etc. to no effect. What am I missing?

Second, the form looks like this:

<form name="content" method="post">
<input type="hidden" size="-1" name="form_validate" value="1">
<input type="hidden" size="-1" name="cid">
<input type="hidden" size="-1" name="cntid">
<input type="hidden" size="-1" name="attid">

I'm sending through a post of

form_validate=1&cid=4343&cntid=&attid=

that is converted by

bytePost = StrConv(bytePostData, vbFromUnicode)

and a header of

sHeader = "Content-Type: " & _
"application/x-www-form-urlencoded" & vbCrLf

Unfortunately, I do not get the expected page.

Any clues?

Thanks,
Richard
 
(e-mail address removed) (RJB) wrote in message
I was clearly having a case of the stupids this mourning.

I should have and am now coding
oInt.Navigate sURL, 0, "", bytePost, sHeader
and now the extra windows are gone. I should note that this problem
is only apparent if the windows are visible, but it's there either
way.

The solution to the second problem, not apparent from my original
post, is that I was (duh) sending through the wrong URL.

BTW, there is a useful knowledge base article HOWTO: Use the PostData
Parameter in WebBrowser Control that the group may want to be aware
of.

Also, there are issues in testing readystate complete when the page
referenced has frames (I'm still working that out, but readystate will
go to complete for each frame as near as I can tell). The example code
I've seen will ocassionally fail (it's also timing dependent). There
are also issues determining if the page actually downloaded (still
working that out as well).

Regards,
RJB
 
Back
Top