Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 94
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 123
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 78
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 74
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 78
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 123
Default 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!
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 78
Default 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.

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 123
Default 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!
  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 94
Default 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!



  #10   Report Post  
Posted to microsoft.public.excel.programming
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!






  #11   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 74
Default 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.



  #12   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 212
Default Web browser question

What Mr. Shetty was talking about was navigationg with instance of IE.
You are trying it for the WebQuery.
It won't work with WebQuery.

Your choices are.
1. First manually open the site and login. Keep the site open, then run
webquery. (Which I think you do at present, is that correct?)

2. If above is correct then before the web query refresh, through VBA code
you start IE, navigate to the url. As Mr. Shetty says, you supply the
username and password through the code. (I don't know exactly how, I hope
Mr. Shetty will inform this.). Leave the navigated site open.
Then run your web query with Worksheets("xyz").QueryTables(1).Refresh

For opening the webpage through excel:
In your VBA project add reference to "Microsoft Internet Control".

Code could be as under:-

Dim IE As InternetExplorer, nCount as Long
Set IE = New InternetExplorer
IE.Navigate "http://in.finance.yahoo.com/p?v&k=pf_2&d=v6"
'code for username/pwd , I don't know how.
IE.Visible = True

'now allow some time for IE to navigate and login
'below loop will give it 10 sec.

nCount = Timer
Do While Timer < nCount + 10
DoEvents
Loop

'Then refresh your webquery

Worksheets("xyz").QueryTables(1).Refresh

'Allow about 30s for query refresh

nCount = Timer
Do While Timer < nCount + 30
DoEvents
Loop

'Then close IE
IE.Quit


"R.VENKATARAMAN" &&& wrote in message
...
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.





  #13   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 74
Default Web browser question

thank you. I am only ding the pedestrian way of things.
await reply from Mr. shetty

Sharad Naik wrote in message
...
What Mr. Shetty was talking about was navigationg with instance of IE.
You are trying it for the WebQuery.
It won't work with WebQuery.

Your choices are.
1. First manually open the site and login. Keep the site open, then run
webquery. (Which I think you do at present, is that correct?)

2. If above is correct then before the web query refresh, through VBA code
you start IE, navigate to the url. As Mr. Shetty says, you supply the
username and password through the code. (I don't know exactly how, I hope
Mr. Shetty will inform this.). Leave the navigated site open.
Then run your web query with Worksheets("xyz").QueryTables(1).Refresh

For opening the webpage through excel:
In your VBA project add reference to "Microsoft Internet Control".

Code could be as under:-

Dim IE As InternetExplorer, nCount as Long
Set IE = New InternetExplorer
IE.Navigate "http://in.finance.yahoo.com/p?v&k=pf_2&d=v6"
'code for username/pwd , I don't know how.
IE.Visible = True

'now allow some time for IE to navigate and login
'below loop will give it 10 sec.

nCount = Timer
Do While Timer < nCount + 10
DoEvents
Loop

'Then refresh your webquery

Worksheets("xyz").QueryTables(1).Refresh

'Allow about 30s for query refresh

nCount = Timer
Do While Timer < nCount + 30
DoEvents
Loop

'Then close IE
IE.Quit


"R.VENKATARAMAN" &&& wrote in message
...
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.







  #14   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 78
Default Web browser question

Sharad,
Thanks for reply. Since its weekend, I will try it on monday at my
office.

Tim,
Sharad is right. I was talking about an instance of the IE. I have not
checked if it works for WebQuery. Your approach to submit the
username/password will not work. I will post the code once I am back to
my office on monday.

Merry Christmas!!!

Shetty




Sharad Naik wrote:
What Mr. Shetty was talking about was navigationg with instance of

IE.
You are trying it for the WebQuery.
It won't work with WebQuery.

Your choices are.
1. First manually open the site and login. Keep the site open, then

run
webquery. (Which I think you do at present, is that correct?)

2. If above is correct then before the web query refresh, through VBA

code
you start IE, navigate to the url. As Mr. Shetty says, you supply the


username and password through the code. (I don't know exactly how, I

hope
Mr. Shetty will inform this.). Leave the navigated site open.
Then run your web query with

Worksheets("xyz").QueryTables(1).Refresh

For opening the webpage through excel:
In your VBA project add reference to "Microsoft Internet Control".

Code could be as under:-

Dim IE As InternetExplorer, nCount as Long
Set IE = New InternetExplorer
IE.Navigate "http://in.finance.yahoo.com/p?v&k=pf_2&d=v6"
'code for username/pwd , I don't know how.
IE.Visible = True

'now allow some time for IE to navigate and login
'below loop will give it 10 sec.

nCount = Timer
Do While Timer < nCount + 10
DoEvents
Loop

'Then refresh your webquery

Worksheets("xyz").QueryTables(1).Refresh

'Allow about 30s for query refresh

nCount = Timer
Do While Timer < nCount + 30
DoEvents
Loop

'Then close IE
IE.Quit


"R.VENKATARAMAN" &&& wrote in message
...
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.




  #15   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 74
Default Web browser question

wish you a happy newyear. take your own time. there is nothing urgent for me

Shetty wrote in message
oups.com...
Sharad,
Thanks for reply. Since its weekend, I will try it on monday at my
office.

Tim,
Sharad is right. I was talking about an instance of the IE. I have not
checked if it works for WebQuery. Your approach to submit the
username/password will not work. I will post the code once I am back to
my office on monday.

Merry Christmas!!!

Shetty




Sharad Naik wrote:
What Mr. Shetty was talking about was navigationg with instance of

IE.
You are trying it for the WebQuery.
It won't work with WebQuery.

Your choices are.
1. First manually open the site and login. Keep the site open, then

run
webquery. (Which I think you do at present, is that correct?)

2. If above is correct then before the web query refresh, through VBA

code
you start IE, navigate to the url. As Mr. Shetty says, you supply the


username and password through the code. (I don't know exactly how, I

hope
Mr. Shetty will inform this.). Leave the navigated site open.
Then run your web query with

Worksheets("xyz").QueryTables(1).Refresh

For opening the webpage through excel:
In your VBA project add reference to "Microsoft Internet Control".

Code could be as under:-

Dim IE As InternetExplorer, nCount as Long
Set IE = New InternetExplorer
IE.Navigate "http://in.finance.yahoo.com/p?v&k=pf_2&d=v6"
'code for username/pwd , I don't know how.
IE.Visible = True

'now allow some time for IE to navigate and login
'below loop will give it 10 sec.

nCount = Timer
Do While Timer < nCount + 10
DoEvents
Loop

'Then refresh your webquery

Worksheets("xyz").QueryTables(1).Refresh

'Allow about 30s for query refresh

nCount = Timer
Do While Timer < nCount + 30
DoEvents
Loop

'Then close IE
IE.Quit


"R.VENKATARAMAN" &&& wrote in message
...
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.








  #16   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 78
Default Web browser question

Hi VENKATARAMAN,
From your post, it seems that you are working to get stock quotes from

the Yahoo finance. I am not sure how much it will help you in the
WebQuery.

Here is the code which
opens yahoo login page
enters username and password
goes to finance page
gives co code to get quotes
opens quotes page
closes IE

You will need to modify it as per your requirement.
Watch for the word wrap.

Regards,


copy and paste following code in a module.
Sub Yahoo_Finance()

' Open Internet Explorer application
Set ie = CreateObject("InternetExplorer.Application")

With ie
..Visible = True
' Go to Yahoo login page
..Navigate "http://login.yahoo.com/"

' Loop until the page is fully loaded
Do Until .ReadyState = 4
DoEvents
Loop

' Make the desired selections on the web page and click the submit
Button
Set ipf = ie.document.all.Item("login")
ipf.Value = "myusername"
Set ipf = ie.document.all.Item("passwd")
ipf.Value = "mypassword"
Set ipf = ie.document.all.Item(".save")
ipf.Click

' Loop until the page is fully loaded
Do Until .ReadyState = 4
DoEvents
Loop
'ask info about company named bombril whose code is bobr3.sa
..Navigate "http://au.finance.yahoo.com/q?m=z&s=bobr3.sa&d=v1"
'for basic view
Do Until .ReadyState = 4
DoEvents
Loop

..Navigate "http://au.finance.yahoo.com/q?s=BOBR3.SA&d=2b" 'for
detailed view
Do Until .ReadyState = 4
DoEvents
Loop
..Navigate
"http://login.yahoo.com/config/login?logout=1&.src=quote&.done=http://au.finance.yahoo.com/%3fu&.intl=au"



End With

ie.Quit
End Sub





R.VENKATARAMAN wrote:
thank you. I am only ding the pedestrian way of things.
await reply from Mr. shetty

Sharad Naik wrote in message
...
What Mr. Shetty was talking about was navigationg with instance of

IE.
You are trying it for the WebQuery.
It won't work with WebQuery.

Your choices are.
1. First manually open the site and login. Keep the site open, then

run
webquery. (Which I think you do at present, is that correct?)

2. If above is correct then before the web query refresh, through

VBA code
you start IE, navigate to the url. As Mr. Shetty says, you supply

the
username and password through the code. (I don't know exactly how,

I hope
Mr. Shetty will inform this.). Leave the navigated site open.
Then run your web query with

Worksheets("xyz").QueryTables(1).Refresh

For opening the webpage through excel:
In your VBA project add reference to "Microsoft Internet Control".

Code could be as under:-

Dim IE As InternetExplorer, nCount as Long
Set IE = New InternetExplorer
IE.Navigate "http://in.finance.yahoo.com/p?v&k=pf_2&d=v6"
'code for username/pwd , I don't know how.
IE.Visible = True

'now allow some time for IE to navigate and login
'below loop will give it 10 sec.

nCount = Timer
Do While Timer < nCount + 10
DoEvents
Loop

'Then refresh your webquery

Worksheets("xyz").QueryTables(1).Refresh

'Allow about 30s for query refresh

nCount = Timer
Do While Timer < nCount + 30
DoEvents
Loop

'Then close IE
IE.Quit


"R.VENKATARAMAN" &&& wrote in message
...
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.






  #17   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 94
Default Web browser question

First, if I havn't said it before, I really appreciate all your help.
That being said, now I am back to where I was before reading about the
WebBrowser object (but in better shape). Have tried out your code as
follows:

Public Sub InitAlphaTrade()
Dim ieAlphaTrade As InternetExplorer

Set ieAlphaTrade = New InternetExplorer
ieAlphaTrade.Visible = True
ieAlphaTrade.Navigate "https://www.alphatrade.com/login"
Do Until ieAlphaTrade.ReadyState = READYSTATE_COMPLETE
DoEvents
Loop

'Log on
Set ipf = ieAlphaTrade.Document.all.Item("userName")
ipf.Value = "Jeannie"
Set ipf = ieAlphaTrade.Document.all.Item("userPassword")
ipf.Value = "mypw"
ifp.Click
ieAlphaTrade.Quit
Set ieAlphaTrade = Nothing

End Sub

I haven't been able to figure out how the ifp.Click can be modified to work
for my case. Something to do with not understanding IE or web pages or
JavaScript or some such. Perhaps someone can help me. Here is a snip from
the HTML ...

<tr
<td bgcolor="#3366cc"
<form method="POST"
action="/com.alphatrade.servlet.http.HttpLoginServlet" target="_top"
ENCTYPE="application/x-www-form-urlencoded" name="loginForm"
onsubmit="doLogin()"
<input type="hidden" name="stageNumber" value="0"
<input type="hidden" name="AppletCodeBase"
value="/E_Gate/tails/java/classes/"
<input type="hidden" name="SiteName" value="AlphaTrade.com"
<input type="hidden" name="logoURL" value="www.alphatrade.com"
<input type="hidden" name="badLoginPage"
value="http://www.alphatrade.com/badlogin.html"
<input type="hidden" name="thanksPage" value="ads.txt"
<table width="450" border="0" cellpadding="8"
<tr
<td width="75" align="right" class="white1"<BLogin Name</b</td
<td<input type="text" name="userName" size="10"
style="background-color:#dfefff"</td
<td rowspan="3" valign="top"<p
style="font-size:9pt;color:#ffffff;"<bDisclaimer</b: &nbsp; As your
agreement for the receipt and use of market data provides, the securities
markets (1) reserve all rights to the market data that they make available;
(2) do not guarantee that data; and (3) shall not be liable for any loss due
either to their negligence or to any cause beyond their reasonable
control.</p</td
</tr
<tr
<td align="right" class="white1"<BPassword</B</td
<td<input type="password" name="userPassword" size="10"
style="background-color:#dfefff"</td
</tr
<tr
<td&nbsp;</td
<td align="center"<input type="image"
src="images/button-login-t.gif"</td
</tr
</table
</form
<script language="JavaScript" type="text/javascript"
document.loginForm.userName.focus();
</script
</td
</tr

Again, my appreciation and Merry Christmas!
-Tim

<snip


  #18   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 74
Default Web browser question

thank you all for clearing the cobwebs in my brain.
I am already downloading yahoo finance (my customised portfolio) by
creating a query and refreshing it a number of times daily for the past one
year. . normally there is no problem because I have configured yahoo to
remember my user id and password in "this" computer and I am able to easily
refresh data. but very occasionally there is a glitch- I don't know whether
this is due to my computer, or I inadvertedly signed out or whether it is
yahoo problem -while refreshing data it asks for user id and password. I
wanted an automation in such circumstances. now I got out of the problem in
my own pedestrian newbie way. In the excel spreadsheet where the
getexternaldata query is located and the data refreshed I inserted a
hyperlink
somewhere which download directly the particular webpage in my default
browser (IE or opera or slimbrowser) . if necessary and if the webpage asks
for it I fill up my user id and password. Only if there is a glitch in
routine refreshing I use this hyperlink and then refresh data. this works.
this is also some sort of automation though in this case I do not use VBA.

thanks once again to all of you for clarifications. It is always useful to
have discussions with those who know more than what I know to clarify some
points.


Shetty wrote in message
oups.com...
Hi VENKATARAMAN,
From your post, it seems that you are working to get stock quotes from

the Yahoo finance. I am not sure how much it will help you in the
WebQuery.

Here is the code which
opens yahoo login page
enters username and password
goes to finance page
gives co code to get quotes
opens quotes page
closes IE

You will need to modify it as per your requirement.
Watch for the word wrap.

Regards,


copy and paste following code in a module.
Sub Yahoo_Finance()

' Open Internet Explorer application
Set ie = CreateObject("InternetExplorer.Application")

With ie
.Visible = True
' Go to Yahoo login page
.Navigate "http://login.yahoo.com/"

' Loop until the page is fully loaded
Do Until .ReadyState = 4
DoEvents
Loop

' Make the desired selections on the web page and click the submit
Button
Set ipf = ie.document.all.Item("login")
ipf.Value = "myusername"
Set ipf = ie.document.all.Item("passwd")
ipf.Value = "mypassword"
Set ipf = ie.document.all.Item(".save")
ipf.Click

' Loop until the page is fully loaded
Do Until .ReadyState = 4
DoEvents
Loop
'ask info about company named bombril whose code is bobr3.sa
.Navigate "http://au.finance.yahoo.com/q?m=z&s=bobr3.sa&d=v1"
'for basic view
Do Until .ReadyState = 4
DoEvents
Loop

.Navigate "http://au.finance.yahoo.com/q?s=BOBR3.SA&d=2b" 'for
detailed view
Do Until .ReadyState = 4
DoEvents
Loop
.Navigate

"http://login.yahoo.com/config/login?logout=1&.src=quote&.done=http://au.fin
ance.yahoo.com/%3fu&.intl=au"



End With

ie.Quit
End Sub





R.VENKATARAMAN wrote:
thank you. I am only ding the pedestrian way of things.
await reply from Mr. shetty

Sharad Naik wrote in message
...
What Mr. Shetty was talking about was navigationg with instance of

IE.
You are trying it for the WebQuery.
It won't work with WebQuery.

Your choices are.
1. First manually open the site and login. Keep the site open, then

run
webquery. (Which I think you do at present, is that correct?)

2. If above is correct then before the web query refresh, through

VBA code
you start IE, navigate to the url. As Mr. Shetty says, you supply

the
username and password through the code. (I don't know exactly how,

I hope
Mr. Shetty will inform this.). Leave the navigated site open.
Then run your web query with

Worksheets("xyz").QueryTables(1).Refresh

For opening the webpage through excel:
In your VBA project add reference to "Microsoft Internet Control".

Code could be as under:-

Dim IE As InternetExplorer, nCount as Long
Set IE = New InternetExplorer
IE.Navigate "http://in.finance.yahoo.com/p?v&k=pf_2&d=v6"
'code for username/pwd , I don't know how.
IE.Visible = True

'now allow some time for IE to navigate and login
'below loop will give it 10 sec.

nCount = Timer
Do While Timer < nCount + 10
DoEvents
Loop

'Then refresh your webquery

Worksheets("xyz").QueryTables(1).Refresh

'Allow about 30s for query refresh

nCount = Timer
Do While Timer < nCount + 30
DoEvents
Loop

'Then close IE
IE.Quit


"R.VENKATARAMAN" &&& wrote in message
...
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.










  #19   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 78
Default Web browser question

Tim,
Sorry, I am not expert in vba or ie.
I have seen your login page and the html source also. This site is
using the method "POST" to login. I never came across this method. The
code I posted will work if the site uses click event or javascript for
login process.
I have done some trials but could not workout the solution.

There are experts here who may help you solving this.

Regards,
Shetty.

  #20   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 94
Default Web browser question

Thanks anyway, Mr Shetty.
"Shetty" wrote in message
oups.com...
Tim,
Sorry, I am not expert in vba or ie.
I have seen your login page and the html source also. This site is
using the method "POST" to login. I never came across this method. The
code I posted will work if the site uses click event or javascript for
login process.
I have done some trials but could not workout the solution.

There are experts here who may help you solving this.

Regards,
Shetty.





  #21   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 212
Default Web browser question

Hello Tim,

In your code, just remove the line 'ifp.Click'
and in its place insert following two lines

Set ifp = ieAlphaTrade.Document.all.Item("loginForm")
ifp.Submit

(i.e. you enter username and password through your code as per your code.
then submit the form, which invokes the 'Post' method on the web site and
you go through)

Sharad

"Tim Coddington" wrote in message
...
Thanks anyway, Mr Shetty.
"Shetty" wrote in message
oups.com...
Tim,
Sorry, I am not expert in vba or ie.
I have seen your login page and the html source also. This site is
using the method "POST" to login. I never came across this method. The
code I posted will work if the site uses click event or javascript for
login process.
I have done some trials but could not workout the solution.

There are experts here who may help you solving this.

Regards,
Shetty.





  #22   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 94
Default Web browser question

Woah!! Thanks Mr Naik!! And this after all hope had been lost.
Works great for this first part.

-Tim

"Sharad Naik" wrote in message
...
Hello Tim,

In your code, just remove the line 'ifp.Click'
and in its place insert following two lines

Set ifp = ieAlphaTrade.Document.all.Item("loginForm")
ifp.Submit

(i.e. you enter username and password through your code as per your code.
then submit the form, which invokes the 'Post' method on the web site and
you go through)

Sharad

"Tim Coddington" wrote in message
...
Thanks anyway, Mr Shetty.
"Shetty" wrote in message
oups.com...
Tim,
Sorry, I am not expert in vba or ie.
I have seen your login page and the html source also. This site is
using the method "POST" to login. I never came across this method. The
code I posted will work if the site uses click event or javascript for
login process.
I have done some trials but could not workout the solution.

There are experts here who may help you solving this.

Regards,
Shetty.







  #23   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 78
Default Web browser question

Its great. As usual, I learnt a new thing from this NG.
Shetty.


Tim Coddington wrote:
Woah!! Thanks Mr Naik!! And this after all hope had been lost.
Works great for this first part.

-Tim

"Sharad Naik" wrote in message
...
Hello Tim,

In your code, just remove the line 'ifp.Click'
and in its place insert following two lines

Set ifp = ieAlphaTrade.Document.all.Item("loginForm")
ifp.Submit

(i.e. you enter username and password through your code as per your

code.
then submit the form, which invokes the 'Post' method on the web

site and
you go through)

Sharad


  #24   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 94
Default Web browser question

Did you see where he got the 'loginForm' from? It is the 'name' from the
'<form method="POST"' section. I found it successfully on the next
automatic login I just tried tonight. (You can tell, it's the simple things
that get me going.)

"Shetty" wrote in message
oups.com...
Its great. As usual, I learnt a new thing from this NG.
Shetty.


Tim Coddington wrote:
Woah!! Thanks Mr Naik!! And this after all hope had been lost.
Works great for this first part.

-Tim

"Sharad Naik" wrote in message
...
Hello Tim,

In your code, just remove the line 'ifp.Click'
and in its place insert following two lines

Set ifp = ieAlphaTrade.Document.all.Item("loginForm")
ifp.Submit

(i.e. you enter username and password through your code as per your

code.
then submit the form, which invokes the 'Post' method on the web

site and
you go through)

Sharad




  #25   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 78
Default Web browser question

In fact, Ihave seen the loginform while conducting some trials. But I
tried to use ipf.click and other combinations which did not work.
Thanks,
Shetty.



  #26   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Web browser question

Tim, Shetty, Sharad, RV,

Thank you, thank you, thank you!! I have been trying to accomplish just
this task (automating Yahoo Finance webpages navigation via vba) and had
given up just about all hope until I discovered this site and this
thread. Being still very new to vba, you all saved me countless hours of
additional trial and error and hunting for info on the web.

That said, I hope some of you are still monitoring this thread because,
of course, I have a couple questions:

ipf.Click

provokes an error -- I got around it by using

Application.SendKeys "~", True

but that makes me nervous because everything I read about SendKeys tells
me it's unreliable. Any sugqestions on clarifying or modifying the Click
event?

Also, my goal is to copy data off the YF pages and into an Excel
spreadsheet. I don't even care about specifying the data to copy, the
whole webpage will do just fine. If I understand correctly, a Web Query
won't work -- or will it? So again, I think I can use the SendKeys, but
is there a more reliable way?

I'm also trying to accomplish the same thing on another website which
does use the Post method for logging in that Tim referenced. Any success
on figuring that one out?

Finally, the latter website uses pull down menus to navigate to other
pages within the site (vs. Yahoo Finances hyperlinks). Can anyone show
me some basic code examples for navigating this type of website
navigation?

Oh, and one more, mostly curiosity question at this point. Can all this
also be accomplished through WebBrowser ActiveX control on a UserForm?
It seems like a handy resource to take advantage of.

Again, thanks so much for all the help!

Regards,

Brian


*** Sent via Developersdex http://www.developersdex.com ***
  #27   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 860
Default Web browser question

Hi Brian,

I'm not sure what thread you're referring to, as I'm posting directly to the
MS news servers, and I don't see the initial thread. That said, a webquery
should do what you want here. Since finance.yahoo.com relies on querystring
values (you can see the stock ticker/etc in the browser's address bar), you
should be able to use webqueries. What I would do is start with a default
webquery (http://finance.yahoo.com/q?s=msft or similar), then you can swap
out the "=msft" for "=<stock ticker" when needed through VBA (just look at
the QueryTable object's Connection property).

For sites that utilize Javascript or use POST methods in their forms, it
becomes a bit trickier. But you may be able to use XMLHTTP to submit the
"form" data and retrieve the text from the resulting page. Here's a brief
example of how it can be accomplished:

http://groups-beta.google.com/group/...829784b4ad0c6b

--
Regards,

Jake Marx
MS MVP - Excel
www.longhead.com

[please keep replies in the newsgroup - email address unmonitored]


braindead wrote:
Tim, Shetty, Sharad, RV,

Thank you, thank you, thank you!! I have been trying to accomplish
just this task (automating Yahoo Finance webpages navigation via vba)
and had given up just about all hope until I discovered this site and
this thread. Being still very new to vba, you all saved me countless
hours of additional trial and error and hunting for info on the web.

That said, I hope some of you are still monitoring this thread
because, of course, I have a couple questions:

ipf.Click

provokes an error -- I got around it by using

Application.SendKeys "~", True

but that makes me nervous because everything I read about SendKeys
tells me it's unreliable. Any sugqestions on clarifying or modifying
the Click event?

Also, my goal is to copy data off the YF pages and into an Excel
spreadsheet. I don't even care about specifying the data to copy, the
whole webpage will do just fine. If I understand correctly, a Web
Query won't work -- or will it? So again, I think I can use the
SendKeys, but is there a more reliable way?

I'm also trying to accomplish the same thing on another website which
does use the Post method for logging in that Tim referenced. Any
success on figuring that one out?

Finally, the latter website uses pull down menus to navigate to other
pages within the site (vs. Yahoo Finances hyperlinks). Can anyone show
me some basic code examples for navigating this type of website
navigation?

Oh, and one more, mostly curiosity question at this point. Can all
this also be accomplished through WebBrowser ActiveX control on a
UserForm? It seems like a handy resource to take advantage of.

Again, thanks so much for all the help!

Regards,

Brian


*** Sent via Developersdex http://www.developersdex.com ***


  #28   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Web browser question


Hi Jack,

Thanks for the suggestion. Problem is that the webpages I need to access
within Yahoo Finance have addresses that are relevant only once signed
into the site. Also querystring values but ones that refer to webpages
containing specifically compiled tables (mutual fund models of stocks
within each fund). Entering these addresses into a web query just
produces the YF login page (unlike individual stock pages that do work
as you noted).

This is why I'm working on automating the login (then I can hopefully
navigate to the useraccount-relevant pages and copy the tables into a
spreadsheet). Problem then with a webquery is that it always opens a new
browser window, so even if I manually login to YF, the subsequent
webquery opens in a new window.

As to the javascript and POST methods of the login forms, further
attention to the thread I referenced (http://www.developersdex.com
"Web browser question") did in fact reveal the solutions to
automatically logging in by using the login page's form data for
username, password, etc.

Now I'm trying to work out the kinks of navigating to the next webpage.
It worked a few times but I can't get it to be consistent.

Thanks again,

Brian


*** Sent via Developersdex http://www.developersdex.com ***
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
what is a web browser msbenz Excel Discussion (Misc queries) 1 October 3rd 06 09:28 AM
Excel and web browser Marcin Kwa¶niewski Excel Programming 6 April 13th 04 11:36 AM
BROWSER David Excel Programming 2 February 3rd 04 11:18 PM
Using Solver in Browser Naveen[_3_] Excel Programming 0 January 3rd 04 02:49 PM


All times are GMT +1. The time now is 04:02 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"