Re: Web browser question

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Shetty (shetty_at_gawab.com)
Date: 12/25/04


Date: 25 Dec 2004 04:57:02 -0800

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 <sharadnaik@nospam-vsnl.net> wrote in message
> news:u9$0Iok6EHA.3908@TK2MSFTNGP12.phx.gbl...
> > 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" <$$$$vram26@vsnl@@@@.net&&&> wrote in message
> > news:eZptZyi6EHA.3708@TK2MSFTNGP14.phx.gbl...
> > > 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 <shetty@gawab.com> wrote in message
> > > news:1103872862.995966.176640@f14g2000cwb.googlegroups.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.
> > >>
> > >
> > >
> >
> >



Relevant Pages

  • Re: Using foreach loop to create radiobutton menu
    ... Your foreach loop is not the problem, the problem is how you define the -command. ... The only possible thing the interpreter can do is substitute the current value of range, which is likely the last value once your loop exited. ... One choice is double quotes. ... The double quotes means that $range gets expanded while in the loop, long before the puts command actually runs. ...
    (comp.lang.tcl)
  • Re: [opensuse] bash - why doesnt the tldp bash beginners guide for loop example work?
    ... I have run into a bash problem with a simple for loop I don't ... As you guessed, the quotes around ... Using some HTML files in one of my ... David Bolt ...
    (SuSE)
  • Re: Fascinating problem with bash
    ... will result in OTHER_VAR being unset at the completion of the loop. ... subshell exits and any vars it sets will go away with it. ... The author uses double quotes for the subshell, ... first echo, to force variable substitution to happen when the loop is ...
    (Debian-User)
  • Re: For vs. For Each
    ... wonder given quotes like: ... "...Even the slightest inefficiency inside a loop is magnified many ... for repetitive property access inside your loops, using foreach instead ... of the garbage collector and JIT compilier. ...
    (microsoft.public.dotnet.languages.vb)
  • Re: reliability problem with Finance::QuoteHist::Yahoo
    ... Sometimes it arises when quotes() is executed, and at other times, it ... Without even looking at your code my guess is that Yahoo! ... reason that free services change their page format is to block people from ... if an individual trader needs a reliable and accurate ...
    (comp.lang.perl.misc)