Link to home
Start Free TrialLog in
Avatar of PatOBrien
PatOBrien

asked on

how to read rtf file in webBrowser control?

I've got a small app (both Access 2000 and VB6) that uses a web Browser control to navigate to a variety of sites.  I then parse the table info or text from the html and populate an Access table.

My problem is that one site that I need ends up delivering an rtf file.  My web Browser control loads the rtf file ok, but I can't seem to find the proper syntax, object properties, methods, etc. to then read the text.

Optionally, I could load the file to a RichTextBox control, but I can't seem to make the .LoadFile method of the RichTextBox control find the file on the internet site.


Any suggestions?

note: I've already tried "webBrowser.document.documentElement.innerHtml" or innerText or just "webBrowser.document.body.innerText" and gotten the error message:
"Object doesn't support this property or method."

It seems that once the rtf file is loaded, all of the normal webBrowser.document properties and methods are invalid.

Avatar of Richie_Simonetti
Richie_Simonetti
Flag of Argentina image

To some extents, yes. i don't know if there is a "DOM" for rtf file format.
Well, as long as i can see, we could manage it like a word document, could you do a check?
(we have to use a better way to know which type of doc is but for testing, this would be enougth, wb1 is webbrowser control. We have to set a reference to microsoft word object library in the project)


Private Sub wb1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
If (pDisp Is wb1.Object) Then
    If Right$(wb1.Document.Name, 3) = "rtf" Then
        Dim wrtf As Word.Document
        Set wrtf = wb1.Document
       
    End If
End If
End Sub

Do an inspection over wrtf var and see...
ASKER CERTIFIED SOLUTION
Avatar of Ark
Ark
Flag of Russian Federation image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of PatOBrien
PatOBrien

ASKER

Richie,

It appears that it can (does) come in as Word Document.

What's next?


Ark,

I'll be trying your functions today.... will let you know what I find.
RTF could be read  to some extents as a Word Document
Better use Ark's code.
Cheers
.... help me go in the right direction.

I added some "On Error" statements and set the function values.

Thanks.
I meant that it "...helped me go in the right direction.