• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 138
  • Last Modified:

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.

  • 3
1 Solution
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
Download the Module containing a function for doing this from the site http://zephyrit.netfirms.com/rtf2html.bas
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...

tobey1Author Commented:
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.Write Module1.RTF2HTML(RichTextBox1.TextRTF)
   End With
End Sub

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now