Josh_with_questions Josh_with_questions - 4 months ago 28x Question

Using RTF in VB.NET to create a document

Thanks for viewing my post. I'm looking for ideas regarding creating a document with rtf. I started using word to create a word document automatically, but word automation does not work too well server side, and it is not recommended to do so by Microsoft. I know how to do basic text with rtf, but I'm wondering if I could create a template with bookmarks and fill in these bookmarks with data from a database. Any ideas would be appreciated. I'm not looking for handouts (ex- coding), just looking for ideas. Thank again for your time! Any info will be greatly appreciated! I'm using



I'm going to go at this in a new way. I'm going to create a html document with 'placeholders'. Then I will call on the document to save with the .doc extension. Testing has shown that Microsoft Word will open this document. Thanks again.


    Public Function GetTemplate( _
        ByVal strTemplateFile As String) As String

        Dim strPath As String = ""

        strPath = Server.MapPath("~/Templates") & "\" & strTemplateFile
        Return My.Computer.FileSystem.ReadAllText(strPath)

    End Function


    Dim strTemplate As String = ""
    Dim blnLB As Boolean = True

    strTemplate = GetTemplate("Legislative_Bulletin.htm")

    Response.AppendHeader("Content-Type", "application/msword")
    Response.AppendHeader("Content-disposition", "attachment; filename=Legislative_Bulletin" & ".doc")

this is just example coding. you will still need to insert the data into the placeholders of the html template. I hope this helps someone!