Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Bob,
Bob Benjamin wrote: Is there a way to modify the following SUB to just parse the LAST TRADE and END OF DAY DATA tables for the Last Traded Rolling 52Week High Rolling Week Low P/E Ratio Earnings/Share Indicated dividend rate values? A cleaner alternative IMO is to automate IE to navigate to the page and grab the necessary values. Here's some code that should do what you want: Private Const msROLLING_52_HIGH As String = "Rolling 52 Week High" Private Const msROLLING_52_LOW As String = "Rolling 52 Week Low" Private Const msPE_RATIO As String = "P/E Ratio" Private Const msDIVIDEND_RATE As String = "Indicated Dividend Rate" Sub GetStockValues() Dim ie As Object Dim s As String Dim nStart As Integer Dim nEnd As Integer Set ie = CreateObject("InternetExplorer.Application") With ie .Navigate "http://www.tse.ca/HttpController?GetPage=QuotesViewPage&D" _ & "etailedView=DetailedPrices&Language=en&QuoteSymbo l_1=bce&x=18&y=7" Do Until Not .Busy And .ReadyState = 4 DoEvents Loop s = ie.Document.body.innertext .Quit End With Set ie = Nothing '/ get rolling 52-wk high nStart = InStr(1, s, msROLLING_52_HIGH, vbTextCompare) If nStart Then nStart = nStart + Len(msROLLING_52_HIGH) nEnd = InStr(nStart, s, vbCrLf) Debug.Print msROLLING_52_HIGH & ": " & Mid$(s, nStart, _ nEnd - nStart) End If '/ get rolling 52-wk low nStart = InStr(1, s, msROLLING_52_LOW, vbTextCompare) If nStart Then nStart = nStart + Len(msROLLING_52_LOW) nEnd = InStr(nStart, s, vbCrLf) Debug.Print msROLLING_52_LOW & ": " & Mid$(s, nStart, _ nEnd - nStart) End If '/ get p/e ratio nStart = InStr(1, s, msPE_RATIO, vbTextCompare) If nStart Then nStart = nStart + Len(msPE_RATIO) nEnd = InStr(nStart, s, vbCrLf) Debug.Print msPE_RATIO & ": " & Mid$(s, nStart, _ nEnd - nStart) End If '/ get dividend rate nStart = InStr(1, s, msDIVIDEND_RATE, vbTextCompare) If nStart Then nStart = nStart + Len(msDIVIDEND_RATE) nEnd = InStr(nStart, s, vbCrLf) Debug.Print msDIVIDEND_RATE & ": " & Mid$(s, nStart, _ nEnd - nStart) End If End Sub -- Regards, Jake Marx MS MVP - Excel www.longhead.com [please keep replies in the newsgroup - email address unmonitored] |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How do I add a portion of a day to a date? | Excel Worksheet Functions | |||
Underline portion of footer with VBA | Excel Discussion (Misc queries) | |||
how do i copy only a portion of a spreadsheet | Excel Discussion (Misc queries) | |||
copy only a portion of a spreadsheet | Excel Discussion (Misc queries) | |||
Protecting a portion of the Sheet | Excel Programming |