View Single Post
  #10   Report Post  
Posted to microsoft.public.excel.programming
Tim Coddington Tim Coddington is offline
external usenet poster
 
Posts: 94
Default Web browser question

OK. I got my username and password field names (userName & userPassword).
From the source, <input type="image" src="images/button-login-t.gif", I
think this is the submit button. Then there is another line,

<form method="POST" action="/com.alphatrade.servlet.http.HttpLoginServlet"
target="_top" ENCTYPE="application/x-www-form-urlencoded" name="loginForm"
onsubmit="doLogin()"

that must capture the 'Login' submit button action to perform the
'doLogin()' routine.
How do I use this information to open this web page without manually
entering the login information?
-Thanks!!!

"Shetty" wrote in message
oups.com...
Hi all,
When it asks for username and password, excel will hold the code
execution.

It is not necessary to create a word doc to enter username and
password.(Atleast in some cases). I had similar problem.
Thru VBA, create a new instance of IE and navigate to the URL which is
asking username and password.
Next, What you need to do is to view the source of the wab page and
findout the codename of the username field and password field.(If you
have Forntpage installed, you can find it out almost instantly. In
frontpage, select normal tab, select the username field (where you will
be entering the username) and then click on the html tab. The html code
for the selected field will be highlighted. Note down the code name of
the username. Repeate the same procedure for the password.

Now, with the help of this data, you will be open the wab page without
manually entering the username and password.

I am not a expert but it works for me.
Hope it works for you also.

Regards,
Shetty.

Sharad wrote:
When it asks for username and password, excel will hold the code
execution. So no use putting code for SendKeys in excel itself.
I made simillar automation program, of checking for new data on a web
site and updating the new data in execl. This program runs 1:00 AM in
the night. What I did is
at 1:00 AM I launch a Winword document (Task Scheduler).
This winword document in it's open even launches the excel workbook
through Shell command, so that the excel application ID is known.
Allowing some time for the username and password dialog box to

appear,
winword sends username and password to the excel using AppActivate
first.

Code in Winword is somplething like this:
(In the winword document, there is a single table with single cell,

to
store the ApplicationID).

Private Sub Document_Open()
Application.OnTime Now + TimeValue("00:00:02"), "OpMyWeb"
End Sub

Then the procedures are in modules as under:

Sub OpMyWeb()
Dim myIDnum As Long
myIDnum = Shell("C:\Program Files\Microsoft Office\OFFICE11
\EXCEL.EXE D:\IntraTrack\WebQuery.xls", vbNormalFocus)
ThisDocument.Tables(1).Cell(1, 1).Select
Selection.Text = myIDnum
Application.OnTime Now + TimeValue("00:00:10"), "EnQuer"
End Sub

So allowing 10 seconds, Procedure EnQuer runs, which is only for
clicking on 'Enable Auto Web Query'. (You may not need this, and you

can
jump to SendPass.)

Sub EnQuer()
Dim myIDnum As Long
ThisDocument.Tables(1).Cell(1, 1).Select
myIDnum = Left(Selection.Text, Len(Selection.Text) - 2)
AppActivate myIDnum
SendKeys "{TAB}", True
SendKeys "{ENTER}", True
ThisDocument.Activate
Application.OnTime Now + TimeValue("00:00:30"), "SendPass"
End Sub

So allowing 30 seconds for username & pwd box to appear, I run

SendPass
procedure, which sends the user name and passowrd, and then winword
document is closed.

Sub SendPass()
Dim myIDnum As Long
ThisDocument.Tables(1).Cell(1, 1).Select
myIDnum = Left(Selection.Text, Len(Selection.Text) - 2)
AppActivate myIDnum
SendKeys "username", True
SendKeys "{TAB}", True
SendKeys "password", True
SendKeys "{ENTER}", True
ThisDocument.Activate
ThisDocument.Saved = True
If Application.Windows.Count = 1 Then Application.Quit
ThisDocument.Close
End Sub

Sharad






*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!