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.docum entElement .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.
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.docum
"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.
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...
(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
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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.
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
Better use Ark's code.
Cheers
ASKER
.... help me go in the right direction.
I added some "On Error" statements and set the function values.
Thanks.
I added some "On Error" statements and set the function values.
Thanks.
ASKER
I meant that it "...helped me go in the right direction.