reading password-protected, open webpage
In a previous post by Jake Marx, he showed a different syntax for InnerText
Sub Demo()
Dim ie As Object
Dim nFile As Integer
Set ie = CreateObject("InternetExplorer.Application")
With ie
.Visible = False
.Silent = True
.Navigate "www.yahoo.com"
Do Until Not .Busy
DoEvents
Loop
nFile = FreeFile
Open "D:\yahoo.txt" For Output Shared As #nFile
Print #nFile, .Document.DocumentElement.InnerText
Close #nFile
.Quit
End With
Set ie = Nothing
End Sub
Using .Document.DocumentElement.InnerText
This did work for me with an open page in IE
Sub Tester1()
Dim IE As Object
Dim sHTML As String
Set IE = GetObject(, "InternetExplorer.Application")
IE.Visible = True
sHTML = IE.Document.Documentelement.innerText
Debug.Print sHTML
Set IE = Nothing
End Sub
--
Regards,
Tom Ogilvy
Kevin wrote in message
...
Thanks Tom.
In my attempts to execute the following code (NOTE: the webpage I want to
read from is already open),
Dim IE As Object
Dim sHTML As String
Set IE = GetObject(, "InternetExplorer.Application")
IE.Visible = True
sHTML = IE.Document.Body.innerText
I get the following error when the program reaches the last line.
Run-time error '-2147467259 (80004005)':
Method 'Document' of object 'IWebBrowser2' failed
Kevin
----- Tom Ogilvy wrote: -----
Can you use GetObject to get the already open instance of IE and then
use
document.body.InnerText?
--
Regards,
Tom Ogilvy
Kevin wrote in message
...
I monitor the performance of my 401(k) by downloading prices from
yahoo.com, using VBA of course. This has become a daily routine.
With fund
prices and number of shares per fund I can determine the dollar value
of
each fund (i.e., current balance). Problem is, the number of shares
per
fund is not something I can download using VBA. This is because the
fund
manager's website is password-protected.
Is it possible to read from an open webpage? If I were to
establish the
target html in a separate IE window, can I use VBA code to read from
it?
That is, rather than navigating to the URL and using
CreateObject("InternetExplorer.Application").Docum ent.Body.innerText
Thanks.
Kevin
|