Link to home
Start Free TrialLog in
Avatar of tobey1
tobey1Flag for United States of America

asked on

Writing an HTM File from a Textbox or Rich Textbox

I need to write a file from the data this is entered into a RichTextBox to an HTM document.  I have written it to a RTF, but when I try to recall that file as part of a web page, using IFRAME (Cause OBJECT won't work), I get the text editor window with the test.  If my information is saved as an HTM, then I get the result in my web for that I need.

Thanks,
Joe
Avatar of rspahitz
rspahitz
Flag of United States of America image

Is there any special formatting in the RTF file?  If not then it should be as simple as:

strHTML = replace(rtbInfo.Text, vbnewline, "<P>" & vbnewline)

When you output strHTML, it will have the line breaks at the proper place.  If you want to get fancier, you can also output it with a header and footer:

open "my_RTF.htm" for output as #1

print #1, "<HTML>"
print #1, "<HEAD>"
print #1, "<TITLE>This used to be RTF</TITLE>"
print #1, "</HEAD>"
print #1, ""
print #1, "<BODY>"
print #1, strHTML
print #1, "</BODY>"
print #1, "</HTML>"

close #1
ASKER CERTIFIED SOLUTION
Avatar of spauljoseph
spauljoseph
Flag of India 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
Sorry. If you click on the link, it will open it in the Explorer. Please Right click the above link and choose Save Target As...

Thanks
Avatar of tobey1

ASKER

What exactly is that link giving me and how can I use it in my ActiveX form?
Thanks for accepting my comments.

Sorry. I've never seen your question in this question as I've forgotten answering this question.

The answer for ur question is...

Juse place a WebBrowser control in your form and an RichTextBox control with a command button named Show.

'Place the following code in the event as mentioned

Private Sub Command1_Click()
   With WebBrowser1
       .Document.Script.Document.Clear
       .Document.Script.Document.Write Module1.RTF2HTML(RichTextBox1.TextRTF)
       .Document.Script.Document.Close
   End With
End Sub