Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Pasting Data into Textboxes in a Web Application

6 views
Skip to first unread message

Childs Family

unread,
Jan 4, 2002, 2:50:22 PM1/4/02
to
Hi

I requested some help on the newsgroup for putting certain text into the
Windows clipboard. Dave Petersen kindly directed me to the method as
specified in Chip Pearson's web site which did indeed put the two items of
text into the clipboard, with a {TAB} separating them.

Unfortunately, the pasting of the clipboard doees not seem to allow the
{TAB} character to act as intended. The Web-based application into which I
want to paste is similar to a Yahoo login, where the first textbox requires,
say, "TimChilds" and the second "mypassword" and I want the cursor to move
programmatically between the two textboxes. Is it possible to do this using
something like the DoEvents/Sendkeys commands.

Any help would be most welcome.

Tim
Oxford, England

PS If someone knows this is not possible (shock horror!), please let me
know.

Jake Marx

unread,
Jan 4, 2002, 5:03:16 PM1/4/02
to
Hi Tim,

There are programmatic ways of doing this that don't involve the clipboard or sendkeys. Depending on the web app, you should be able to post information to a page directly without bothering with physically filling out the HTML form.

Please reply with what page you want to access (the specific URL), and somebody will be able to come up with some code to do it.

Regards,

Jake Marx
Excel MVP

"Childs Family" <ts...@lineone.net> wrote in message news:O4ygZoVlBHA.1812@tkmsftngp03...

Jake Marx

unread,
Jan 4, 2002, 6:09:26 PM1/4/02
to
Hi Tim,

I just wanted to add some information to my previous reply. To show you that this can be done programmatically, here's a subroutine that will log you in to Hotmail given a valid username/password:

Sub LoginToHotmail(rsUsername As String, rsPassword As String)
Dim ie As Object
Dim sURL As String
Dim sHeader As String
Dim bytPostData() As Byte

Set ie = CreateObject("InternetExplorer.Application")

sURL = "https://lc3.law13.hotmail.passport.com/cgi-bin/dologin"
bytPostData = "domain=hotmail.com&login=" & rsUsername _
& "&passwd=" & rsPassword & "&svc=mail&RemoteDAPost=" _
& "https://login.msnia.passport.com/ppsecure/post.asp&" _
& "sec=share&curmbox=ACTIVE&js=yes&_lang=EN&ishotmail=1" _
& "&is=2&fs=1&cb=_lang%3dEN&ct=1010184077&mspp_shared=1"

Debug.Print bytPostData

bytPostData = StrConv(bytPostData, vbFromUnicode)
sHeader = "Content-Type: " & _
"application/x-www-form-urlencoded" & vbCrLf
ie.Navigate sURL, 0, "_self", bytPostData, sHeader

ie.Visible = True
Set ie = Nothing
End Sub


This is a little more complicated than most form submisisions would be, as MS has included a bunch of hidden textboxes. And with the frequency that they change the login page, this routine may soon stop working. However, this should give you the basic idea on how it can be done. The first thing you need to do is to determine where the form is being submitted. You can look at the source of the HTML page and look for the <form> tag - the value of the action attribute is what you should use for the sURL variable in my subroutine. bytPostData should contain all of the form element name/value pairs, separated by "&". So if your form has two inputs, one named "username" and the other "password", and your username is "tim" and your password is "test", you would do this:

bytPostData="username=tim&password=test"

Hope that makes some sense. Try it on your own to see if you can get it to work - if not, let us know and someone will be able to help you out.

Regards,

Jake Marx
Excel MVP


"Childs Family" <ts...@lineone.net> wrote in message news:O4ygZoVlBHA.1812@tkmsftngp03...

Childs Family

unread,
Jan 5, 2002, 3:09:12 PM1/5/02
to
Hi

I have tried to take this forward using my current Yahoo web e-mail but
there is no sign of a password in the Web URL's, which are shown below.

(where is the place for the password?)


prior to putting login details
http://edit.europe.yahoo.com/config/login?.intl=uk&.partner=&.src=ym&.done=h
ttp%3a//mail.yahoo.com/

after putting in log-in details and pressing return
http://uk.f136.mail.yahoo.com/ym/login?.rand=4cu57kqrng847

I tried the macro out and it did get me into the web immediately which is a
great improvement on what I'd achieved on my own.

Also, in the application (a financial package) which I want to paste into
when I have sorted the basics out there are no vivible parameters in the
URL - how will I paste my Excel data (loads of cells) into the application.
Hope I haven't misled you by mentioning Web mail....

Many thanks for your help

Tim


Jake Marx

unread,
Jan 5, 2002, 5:38:13 PM1/5/02
to
Hi Tim,

There are two types of HTML forms - ones that POST data, and ones that GET data. POST operations don't show the values in the address bar (URL), while GET operations show up in the querystring (i.e. ?username=tim&password=test). Most login forms use POST, as the Yahoo! one you pointed to does. To find the POST data, you have to look in the HTML source for any <input> tags (or <select>, <textarea>, other form elements).

In the case of the Yahoo! login page you mentioned, you can look at the source and see the following two input elements:

<input name="login" size="17" maxlength="32" value="">
<input name="passwd" type="password" size="17" maxlength="32">

You get the name from the name attribute and the value from the value attribute (or whatever you want the value to be when the form is submitted). So if your username is "tim" and your password is "test", part of your POST data would include "login=tim&passwd=test". There are also several hidden <input> elements that should be included in the POST data - you'll see each of them in the source as well.

The web application you want this to work for should be easier than the Yahoo! login page if that's any consolation. <g>

Regards,

Jake Marx
Excel MVP


"Childs Family" <ts...@lineone.net> wrote in message news:eGYuyTilBHA.804@tkmsftngp03...

Childs Family

unread,
Jan 6, 2002, 2:04:40 PM1/6/02
to
Hi

Many thanks for further explanation which you have given.

how do you look at the source code for a POST page on HTML - excuse my
ignorance!

Many thanks, again

Tim


Jake Marx

unread,
Jan 6, 2002, 7:11:42 PM1/6/02
to
Hi Tim,

You need to view the source of the HTML document that contains the form. If you're using IE, you can right-click on a "blank" spot in the page and select View Source. Or you can select Source from the View menu. If you're using Netscape, select View | Page Source or right-click and select View Source.

This will bring up the source of the HTML document in either Notepad or some other text editor. You can't modify the source from there, but you can look at it. Just do a search in the source for the string "<form" and you'll find the <form> tag. You can search for "<input" to find each of the form's textboxes. You may wish to look for others such as "<select" or "<textarea" as well.

Regards,

Jake Marx
Excel MVP


"Childs Family" <ts...@lineone.net> wrote in message news:OSpZ$TulBHA.1952@tkmsftngp02...

Childs Family

unread,
Jan 7, 2002, 5:19:16 PM1/7/02
to
Jake

Thanks for this next step - worked a treat in terms of getting the Source.

Will now tie this back to the work on pasting

This'll keep going for a few days as I need to get on with the "day" job as
well (accountancy)!

Tim


Childs Family

unread,
Jan 21, 2002, 9:54:26 PM1/21/02
to
Hi

have been trying to progress this

What I 'd ppreciate help on is working out which parts need to be
incorporated into the code, which in the 4 Jan post was:


sURL = "https://lc3.law13.hotmail.passport.com/cgi-bin/dologin"
bytPostData = "domain=hotmail.com&login=" & rsUsername _
& "&passwd=" & rsPassword & "&svc=mail&RemoteDAPost=" _
& "https://login.msnia.passport.com/ppsecure/post.asp&" _
& "sec=share&curmbox=ACTIVE&js=yes&_lang=EN&ishotmail=1" _
& "&is=2&fs=1&cb=_lang%3dEN&ct=1010184077&mspp_shared=1"


Is the above sURL based on just the URL? I found the hotmail.com URL to be:
http://lc2.law13.hotmail.passport.com/cgi-bin/login


The standard URL on Yahoo is below:
http://edit.europe.yahoo.com/config/login?logout=1&.intl=uk&.src=ym&.partner
=&.done=http%3a//edit.europe.yahoo.com/config/login%3f.intl=uk%26.partner=%2
6.src=ym%26.done=http%253a//mail.yahoo.com/

How do I puzzle out where to put the userID and password, please? I would
like the method rather than the "pure" answer alone, please

Thanks

Tim


Jake Marx

unread,
Jan 25, 2002, 11:35:10 AM1/25/02
to
Hi Tim,

OK - comments inline:

> What I 'd ppreciate help on is working out which parts need to be
> incorporated into the code, which in the 4 Jan post was:
> sURL = "https://lc3.law13.hotmail.passport.com/cgi-bin/dologin"
> bytPostData = "domain=hotmail.com&login=" & rsUsername _
> & "&passwd=" & rsPassword & "&svc=mail&RemoteDAPost=" _
> & "https://login.msnia.passport.com/ppsecure/post.asp&" _
> & "sec=share&curmbox=ACTIVE&js=yes&_lang=EN&ishotmail=1" _
> & "&is=2&fs=1&cb=_lang%3dEN&ct=1010184077&mspp_shared=1"
>
> Is the above sURL based on just the URL? I found the hotmail.com URL to
be:

No, sURL is based on the target attribute of the <form> tag within that
page. Look for the <form> tag, and it should have an attribute named
target - use the value of that attribute for sURL.

> The standard URL on Yahoo is below:
>
http://edit.europe.yahoo.com/config/login?logout=1&.intl=uk&.src=ym&.partner
>
=&.done=http%3a//edit.europe.yahoo.com/config/login%3f.intl=uk%26.partner=%2
> 6.src=ym%26.done=http%253a//mail.yahoo.com/
>
> How do I puzzle out where to put the userID and password, please? I would
> like the method rather than the "pure" answer alone, please

The userID and password will most likely be POSTed to the sURL address.
That means you can look for <input> tags of type "text" or "password". So
you would use the name attribute of those tags, along with the values you
enter in the textboxes as part of the bytPostData string. For example, if
your form looks like this:

<form name="test" target="http://www.test.com/default.asp" action="post">
<input name="txtUserName" type="text" />
<input name="pwdPassword" type="password" />
</form>

and your username is "timchilds" and password is "timspassword",

then sURL would be = "http://www.test.com/default.asp", and bytPostData
would start with "txtUserName=timchilds&pwdPassword=timspassword".

Hope that helps you along a bit.

Childs Family

unread,
Feb 1, 2002, 7:32:01 AM2/1/02
to
Thanks for this - I have been away so have only just "found" it. It should
help.

Tim


Tim Childs

unread,
Feb 8, 2002, 1:56:43 PM2/8/02
to
Hi

I have managed to get into the e-mail but have the following problems.

The first is that I end upp in the wrong part of yahoo i.e. I am in
"My Yahoo" i.e. "http://my.yahoo.com/" which I don't ever go to as I
am only interested in the e-mail.

The second minor problem is that a second window opens.

I have posted the code below, bar my password(!) for information

Many thanks, Jake, for all the help so far.

Tim


Sub RunLogin()
Call LoginToYahoo("tsnip1", "PWORD")
End Sub

Sub LoginToYahoo(rsUsername As String, rsPassword As String)


Dim ie As Object
Dim sURL As String
Dim sHeader As String
Dim bytPostData() As Byte

Set ie = CreateObject("InternetExplorer.Application")

sURL= "http://login.yahoo.com/config/login?.src=ym&.lg=uk&.done=http://edit.yahoo.com/config/mail%3f.intl=uk&.intl=uk"

bytPostData = "login=" & rsUsername & "&passwd=" _
& rsPassword '"domain=yahoo.co.uk&

Debug.Print bytPostData
bytPostData = StrConv(bytPostData, vbFromUnicode)

sHeader = "Content-Type: " & "application/x-www-form-urlencoded" &
vbCrLf
ie.Navigate sURL, 0, " self", bytPostData, sHeader

Jake Marx

unread,
Feb 8, 2002, 3:37:36 PM2/8/02
to
Hi Tim,

I don't know what else you can try. Just make sure you have included all of
the <input> tags in bytPostData. Even the <input type="hidden"> ones.

Regards,

Jake Marx
Excel MVP


"Tim Childs" <tsn...@yahoo.co.uk> wrote in message
news:f4efb325.02020...@posting.google.com...

Childs Family

unread,
Feb 17, 2002, 4:26:02 AM2/17/02
to
Jake

Just a quick note to say a big thank- you for the help in getting this
log-on to work.

A friend who tested the Hotmail log-in was dead impressed!

On the work I did to do the Yahoo log-in, I needed in the end to comment out
the statement

ie.visible = true

to get the unwanted window of IE to disappear - any idea why?

I now hope to use the working version to enable pasting of data into the
financial application but this will no doubt introduce some more problems..!
(I think with a following wind, I'll get it working before I retire!)

MANY THANKS FOR ALL THE HELP

Tim


Childs Family

unread,
Feb 21, 2002, 5:46:23 PM2/21/02
to
What changes do I need to make to the code to stop the information being
POSTED without being checked - so, for example, in a financial accounting
scenerio I would want to review the data (brought in from a spreadsheet to a
Web page) on screen before the items are submitted. Is this possible?

In the hotmail situation, it would be analogous to enterin the login-name
programmatically but leaving the password to be filled in manually. If this
is not possible or is simply too unwieldy, I'd be pleased to know.

I have put the relevant code down below for reference.

TIA

Tim


Sub LoginToHotmail(rsUsername As String, rsPassword As String)


Dim ie As Object
Dim sURL As String
Dim sHeader As String
Dim bytPostData() As Byte

Set ie = CreateObject("InternetExplorer.Application")

sURL = "https://lc3.law13.hotmail.passport.com/cgi-bin/dologin"


bytPostData = "domain=hotmail.com&login=" & rsUsername _
& "&passwd=" & rsPassword & "&svc=mail&RemoteDAPost=" _
& "https://login.msnia.passport.com/ppsecure/post.asp&" _
& "sec=share&curmbox=ACTIVE&js=yes&_lang=EN&ishotmail=1" _
& "&is=2&fs=1&cb=_lang%3dEN&ct=1010184077&mspp_shared=1"

Debug.Print bytPostData

bytPostData = StrConv(bytPostData, vbFromUnicode)
sHeader = "Content-Type: " & _
"application/x-www-form-urlencoded" & vbCrLf
ie.Navigate sURL, 0, "_self", bytPostData, sHeader

Childs Family

unread,
Mar 4, 2002, 5:21:46 PM3/4/02
to
Hi

I still have a problem associated with the pasting of data into POST forms
on Web pages. Two of the fields are entered via a "hyperlink" and I have
looked at the Source code for each page.

The Source code on the original page does not include the parameters on the
linked page with the two fields but the URL is the same for both pages, so I
think I am stuck: I can only post the fieldsto the initial page - that IS
working fine now.

Hope the explanation is clear but if not please let me know.

Thanks

Tim

PS if someone can recommend a good reference explaining the POST technique
etc, I'd be grateful.


0 new messages