Open Rich Text File in asp

Posted on 2007-10-21
Last Modified: 2012-06-22
How do you open a rich text file actually read rtf in asp
Question by:thenone
    LVL 17

    Accepted Solution

    Hi thenone,

    Rich Text files can also be open as text files. However, like HTML, it contains "tags" to give format the text. A example can be read from;EN-US;Q270906&ID=KB;EN-US;Q270906

    If you are trying to open a rich text file in the browser, then it can done by by forcing the rich text to be opened with MS Word since Word can interpret rich text files.
    Place the below code at the top of the page and then you can use FileSystemObject to read the rich text file.
    <%Response.ContentType = "application/msword"%>
    Function ReadFile(filename)
      Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
          If objFSO.FileExists(Server.MapPath(filename)) Then
                Set objTStream = objFSO.OpenTextFile(Server.MapPath(filename), ForReading)
                strText = objTStream.ReadAll
                Set objTStream = Nothing
                Set objFSO = Nothing
                ReadFileOrig = strText
          End If
    End Function
    <% Response.Write ReadFile("YourRichTextFile.rtf") %>

    LVL 8

    Author Comment

    doesn't Microsoft Word have to be installed on the clients machine?
    LVL 17

    Expert Comment

    Yes, either that or have MS Word Viewer which can be freely downloaded.

    LVL 8

    Author Comment

    so ms word viewer has to be installed on the clients machine?

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Suggested Solutions

    I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:  The Exchange of information …
    I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
    In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    10 Experts available now in Live!

    Get 1:1 Help Now