Results 1 to 12 of 12

Thread: Get Active IE Contents Into Worksheet

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #10
    Hi there!

    thanks mvidas for the code, that one works for me. Actually, i've posted a similar inquiry to other forum (i've stated what i do manually and ask vba expert on other forum for the vba code). I'm lucky to find the code here in vbaexpress without even posting an inquiry.

    Anyways, I would like to ask if its possible to revised the code below , instead of looking at all open brower or internet explorer, it will get the html code of the specific url?

    For Each vIE In SWs
    If Left(vIE.LocationURL, 4) = "http" Then 'avoid explorer windows/etc this way
    If MsgBox("IE Window found. The URL is:" & vbCrLf & vIE.LocationURL & vbCrLf & _
    vbCrLf & "Do you want to see the html?", vbYesNo) = vbYes Then

    'Show html in a msgbox
    MsgBox vIE.Document.Body.innerHTML

    'Or put it to a file
    dim vFF as long
    vff=freefile
    open "C:\thehtml.txt" for output as #vff
    print #vff,vie.document.body.innerhtml
    close #vff
    End If
    End If
    Next
    Also, i want vba to automatically input the text (the one in red font) or change the text of the input box then click go or press enter and get the html code for me and instead of saving it as open "C:\thehtml.txt", the filename should be the same as the value or text in the input box PLUS the time. I need to include the time cause i have to get the information every 3 mins or less depends upon the activity of the stock, then i will have a post analysis after the end of trading.

    Below is a part (i think) that vba should control to change the text
    <FORM name=search onsubmit="return ValidateSearch(this);" action=quotes.asp method=get>
    <INPUT size=10 value=ABCDEFGHIJ name=code> <INPUT type=hidden value=SI name=type> </FORM>
    </DIV>
    <DIV id=golinks><B><A href="javascript:submitForm(document.search);">GO</A> |
    </B><A href="javascript:SymbolGuide();">SYMBOL GUIDE</A> </DIV>
    <SCRIPT language=javascript>
    document.search.code.focus();
    </SCRIPT>
    Thanks in advance for your help..

    by the way, i don't have any programming background.


    Quote Originally Posted by mvidas
    I got it from your code above!

    Anyways.... yes to avoid the query table, you would have to play with the html. As a start (in order to help with the table parsing further, I would need to know what it looks like):
    [vba]Function RetrieveQueryTable() As Boolean
    'Requires reference to Microsoft Internet Controls
    'Should work with any web table, provided it is not in a frame!
    'Can change the coreURL to be assigned from a worksheet
    Dim SWs As SHDocVw.ShellWindows, vIE As SHDocVw.InternetExplorer

    'Incoporate error handling
    On Error GoTo ExitRoutine

    'Establish link to IE application
    Set SWs = New SHDocVw.ShellWindows

    For Each vIE In SWs
    If Left(vIE.LocationURL, 4) = "http" Then 'avoid explorer windows/etc this way
    If MsgBox("IE Window found. The URL is:" & vbCrLf & vIE.LocationURL & vbCrLf & _
    vbCrLf & "Do you want to see the html?", vbYesNo) = vbYes Then

    'Show html in a msgbox
    MsgBox vIE.Document.Body.innerHTML

    'Or put it to a file
    dim vFF as long
    vff=freefile
    open "C:\thehtml.txt" for output as #vff
    print #vff,vie.document.body.innerhtml
    close #vff
    End If
    End If
    Next

    ExitRoutine:
    If Err.Number <> 0 Then
    RetrieveQueryTable = False
    Else
    RetrieveQueryTable = True
    End If

    On Error GoTo 0

    Set SWs = Nothing
    Set vIE = Nothing
    End Function[/vba]
    Since you already have IE open and want whats on the visible page, there is no reason to not use the IE object. Since it seems like there is a specific type of table you want on the results (based on table #6), we should be able to find the pattern of the table in the html and parse it from there. if its a sensitive site then either email me the file, post it here then delete it later, or parse it yourself. I'd recommend regexp for it, but I recommend that for everything. I'd brush my teeth with it if i could
    Last edited by StreetTrader; 11-16-2007 at 01:46 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •