Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

what does this code do??

Status
Not open for further replies.
By the name (I haven't downloaded it) it says that it converts a RTF (rich-text-format) document into an HTML document.

Chip H.
 
As far as I can see you just open the RTF and put it in a string variable and pass it to the function and it will pass you back a string that you can stick in a .html file. Durkin
alandurkin@bigpond.com
 
Compnut24, that was an interesting piece of code you pointed out. I downloaded it but I couldn't get it to work properly.

There appears to be a bug in the loop that scans the body of the rich text. I emailed the author to see if he was aware of any issues.

Back to your original question. You need to click Project, then Add Module. Browse for RTF2HTML.BAS and double-click it.

After opening the file you will see this:[tt]
Function RTF2HTML(strRTF As String, Optional strOptions As String) As String[/tt]


This is the header for the function you want to incorporate and gives you some clues about the way you should call it from your program. The strOptions parameter is optional but here are the options you might want to pass:
+H add an HTML header and footer
+G add a generator Metatag
+T="MyTitle" add a title (only works if +H is used)

After placing a command button and a text box on a form, here's what I did to test the function:
[tt]
Private Sub Command1_Click()
Dim strRTF As String
Dim strOptions As String
MyFile$ = "C:\VBLinks.rtf"[/tt]
'the name of my RTF file[tt]
ff = FreeFile
Open MyFile$ For Binary As #ff
strRTF = String$(Lof(ff), 32) [/tt]
'a string the size of my file[tt]
Get #ff, 1, strRTF [/tt]
'read the file into the strRTF string[tt]
Close #ff
strOptions = "+H+G+T=""This is the HTML Title"""[/tt]

' Then place the results in the text box[tt]
Text1.Text = RTF2HTML(strRTF, strOptions)
End Sub
[/tt]

Let me know if you have any success with the RTF2HTML function. It looks like a pretty neat piece of work.

VCA.gif

Alt255@Vorpalcom.Intranets.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top