Frank -
You didn't specify which platform you are targeting. However, the fact you mentioned VBScript as well as Javascript suggests you are at the least using a Windows-based machine. If so, and you have access to a version of Word, you could use a script automating a conversion, using Word as an out of process server. Even then, you didn't really say whether this is meant to be done from a Windows session, or via a web server.
If you wanted to do this from a Windows session, you could use the following VBScript, run by the Windows Scripting Host:
[Rtf2Html.vbs]
Option Explicit
Private Sub ConvertToHtml(documentFileName)
Const wdFormatHTML = 8
Dim fso
Dim wordApplication
Dim newDocument
Dim htmlFileName
On Error Resume Next
Set fso = WScript.CreateObject("Scripting.FileSystemObject")
documentFileName = fso.GetAbsolutePathName(documentFileName)
If Not fso.FileExists(documentFileName) Then
WScript.Echo "The file '" & documentFileName & "' does not exist."
WScript.Quit
End If
Set wordApplication = WScript.CreateObject("Word.Application")
If Err.Number <> 0 Then
Select Case Err.Number
Case &H80020009
WScript.Echo "Word not installed properly."
Case Else
ShowDefaultErrorMsg
End Select
wordApplication.Quit
WScript.Quit
End If
Set newDocument = wordApplication.Documents.Open(documentFileName, False)
If Err.Number <> 0 Then
Select Case Err.Number
Case Else
ShowDefaultErrorMsg
End Select
wordApplication.Quit
WScript.Quit
End If
' Construct a file name which is the same as the original file, but with a different extension.
htmlFileName = Left(documentFileName, InStrRev(documentFileName, ".")) & "htm"
newDocument.SaveAs htmlFileName, wdFormatHTML
newDocument.Close
wordApplication.Quit
End Sub
Private Sub Main
Dim arguments
Set arguments = WScript.Arguments
If arguments.Count = 0 Then
WScript.Echo "Missing file argument."
Else
ConvertToHtml arguments(0)
End If
End Sub
bad
Private Sub ShowDefaultErrorMsg
WScript.Echo "Error #" & CStr(Err.Number) & vbNewLine & vbNewLine & Err.Description
End Sub
Main
If you want to use this from a webserver, things are a little different. You could adapt the VBScript for an ASP page, or convert it to an ASP.NET page. In any case, you will have to replace the WSH objects with the appropriate internal objects. However, be warned: whilst it is possible to use an out of process server from IIS, it is generally a bad idea, unless you know this is going to be an extremely low volume server. Even then, the fact that Word potentially uses GUI elements makes this potentially dangerous, because it is possible that Word might show a dialogue in some error condition.
In this case, it may be better to disconnect the two processes by shelling out from the server script to the Windows scripting host code, and instead return a page that does a client side pull after an appropriate delay.