Home |
Search |
Today's Posts |
|
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Web browser question
So I made a form to use for browing the WWW. In the form initialization, I
navigate to a target. In the form activation, I set the window size and position. The next thing I need to do is send some data to the form, as there is a log on screen which I must go through. I use 'Sendkeys' to send 'usrnam' and 'passwrd'. But if I place it in the initialization or activation subroutines, it never reaches the browser window. I apparently must complete the activation phase to use 'Sendkeys'? How do I get my name and pw sent to the browsed object? |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Web browser question
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! |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Web browser question
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! |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Web browser question
I am also interested in this. I edited the concerned webpage thrugh
frontpage and I got these lines(hope they are the relevant portions) ------ <td align="right" nowrap class="bodywhite"Yahoo! ID:</td <td align="right"<input name="login" size="17" value=""</td </tr <tr <td align="right" nowrap class="bodywhite"Password:</td <td align="right"<input name="passwd" size="17" value="" type="password"</td ------------- which are the codes? are they "login" and "passwd" highly thankful for your claification.. 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! |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Web browser question
YA, IT IS LOGIN AND PASSWD.
YOU CAN USE IT IN YOUR VBA CODE TO SUPPLY THE VALUES. ALSO YOU NEED TO FIND OUOT THE CODE NAME FOR SUBMIT BUTTON TO SUBMIT THE FROM PROGRAMATICALLY. REGARDS, SHETTY. |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
Web browser question
thank you Mr.shetty;. I got the code for submit also. but I do not know how
to dovetail thee codes into the vba statement my code call the url b this statement ==== With ActiveSheet.QueryTables.Add(Connection:= _ "URL;http://in.finance.yahoo.com/p?v&k=pf_2&d=v6", Destination:=Range("B5")) .Name = "p?v&k=pf_2&d=v6" etc. ..FieldNames = True .RowNumbers = False .FillAdjacentFormulas = False etc etc yahoo sometimes call for logging in. ================== I tried to place the following code statements in the beginning before the above statements. that does not seem to help. Dim login Dim passwd Dim submit As Boolean login = "venkat1926" passwd = InputBox("type password") submit = True thanks for all the help Shetty wrote in message oups.com... YA, IT IS LOGIN AND PASSWD. YOU CAN USE IT IN YOUR VBA CODE TO SUPPLY THE VALUES. ALSO YOU NEED TO FIND OUOT THE CODE NAME FOR SUBMIT BUTTON TO SUBMIT THE FROM PROGRAMATICALLY. REGARDS, SHETTY. |
#7
Posted to microsoft.public.excel.programming
|
|||
|
|||
Web browser question
Well Shetty, if username and passowrd entry is in the web page script then these can be supplied through the VBA code (or even in the worst case, SendKeys will also work since Excel will not hold the code execution.) But if the site uses windows login, a seperate dialogue box asking for username and passowrd pops up. Here it is not possible to supply the username and password through VBA code. Excel will hold the execeution of code. That's when you need to use SendKeys from another application (one of the ways, there could be better way which I would like to know.) Since OP mentioned SendKeys I assumed that that web site uses Windows login. Sharad *** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it! |
#8
Posted to microsoft.public.excel.programming
|
|||
|
|||
Web browser question
YES, YOU ARE RIGHT.
SINCE I WAS INVOLVED IN WEB PAGE SCRIPTS IN MY CURRENT PROJECT, I REPLIED ACCORDINGLY. I WILL ALSO SAVE YOUR PREVIOUS POST FOR REFERANCE IN FUTURE. IS THERE ANYWAY TO FINDOUT WEATHER IE HAS GENERATED ANY MESSAGEBOX? I CREATE A INSTANCE OF IE AND THEN NAVIGATE TO THE REQUIRED URL WITH USERNAME AND PASSWORD. IF THERE IS ANY ERROR, THEN IE WILL GENERATE A MESSAGE BOX OF THE ERROR AND WILL RETURN TO THE LOGIN PAGE. IN SUCH CASE I WOULD LIKE TO ASK USER TO AGAIN INPUT THER USERNAME AND PASSWORD, PROGRAMATICALLY CLICK ON OK BUTTON OF MESSAGEBOX AND AGAIN INITIATE THE LOGIN PROCESS. USER WILL NOT BE ABLE TO SEE THE ERROR MESSAGEBOS COZ I KEPT IE HIDDEN. REGARDS, SHETTY. |
#9
Posted to microsoft.public.excel.programming
|
|||
|
|||
Web browser question
There is no any direct way to find out if IE has generated a message box
(I am talking about Reference to MS Internet Control). However, if you are launching IE with a URL first time, if you give command to GoForward, it will normall generate error "Unspecified error", if no any dialogue box is active in IE. If a dialogue box is active in IE, then on GoForward, it gives another error "resource is in use." Using this, it is possible to determine if a IE has generated a dialogue box. Below is a sample code (Reference to MS Internet Control) In the below code I allow 10 seconds before giving the GoForard command and checking what error it has generated. If your site takes longer you can adjust the number of seconds. You can check the below code by purposefully giving wrong password. Regards Sharad Sub Rediculous() Dim IE As InternetExplorer, nCount As Long Set IE = New InternetExplorer IE.Navigate "Your website url" 'your code for username/pwd but give WRONG PWD to test IE.Visible = True 'below I allow 10 seconds to load 'you can change the seconds as per your site speed nCount = Timer Do While Timer < nCount + 10 DoEvents Loop On Error Resume Next IE.GoForward If InStr(1, Err.Description, "resource is in use", vbTextCompare) 0 Then 'Now this means a dialog box is active in IE AppActivate IE 'activate IE which by default activates the dailogue window SendKeys "{ENTER}", True ' your further code to send username and pwd End If On Error GoTo 0 'Further code if no any dialogue box is active in IE End Sub *** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it! |
#10
Posted to microsoft.public.excel.programming
|
|||
|
|||
Web browser question
I mentioned SendKeys because I'm new at this. I guess now, I
have my work cut out for me. Thanks all; this will get me started. -Tim "Sharad" wrote in message ... Well Shetty, if username and passowrd entry is in the web page script then these can be supplied through the VBA code (or even in the worst case, SendKeys will also work since Excel will not hold the code execution.) But if the site uses windows login, a seperate dialogue box asking for username and passowrd pops up. Here it is not possible to supply the username and password through VBA code. Excel will hold the execeution of code. That's when you need to use SendKeys from another application (one of the ways, there could be better way which I would like to know.) Since OP mentioned SendKeys I assumed that that web site uses Windows login. Sharad *** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it! |
#11
Posted to microsoft.public.excel.programming
|
|||
|
|||
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! |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
what is a web browser | Excel Discussion (Misc queries) | |||
Excel and web browser | Excel Programming | |||
BROWSER | Excel Programming | |||
Using Solver in Browser | Excel Programming |