Skip to content Skip to sidebar Skip to footer

Return Entire Page Text From Ie Object

I'm using regex with VBA to pick up e-mails on webpages, all of which are formatted very differently. I'm struggling to access the entire page text owing to these differences in fo

Solution 1:

It is working just fine for me. I have a feeling that you are writing that to an Excel cell and hence the text is getting truncated.

I wrote it to a text file and I got the complete text.

Sub Sample()
    Dim ie AsObject
    Dim retStr AsString

    Set ie = CreateObject("internetexplorer.application")

    With ie
        .Navigate "http://www.wikihow.com/Choose-an-Email-Address"
        .Visible = True
    End With

    DoWhile ie.readystate <> 4: Wait 5: Loop

    DoEvents

    retStr = ie.document.body.innerText

    '~> Write the above to a text file
    Dim filesize As Integer
    Dim FlName As String

    '~~> Change this to the relevant path
    FlName = "C:\Users\Siddharth\Desktop\Sample.Txt"

    filesize = FreeFile()

    Open FlName For Output As#filesizePrint#filesize, retStr
    Close #filesize
End Sub

Private Sub Wait(ByVal nSec As Long)
    nSec = nSec + Timer
    While nSec > Timer
        DoEvents
    Wend
End Sub

Post a Comment for "Return Entire Page Text From Ie Object"