How do I write a file in RTF format using Visual Basic 2008?

Posted on 2009-02-13
Last Modified: 2013-11-27
I am currently developing a program using the Visual Basic component of Visual Studio 2008.

I have to produce a file in rich text format so as not to restrict it to a particular word processor such as MS Word. However, I have never done this before and have no idea how I write the file in RTF.

Can someone either describe the process or point me to some website where I can get something more descriptive than I have been able to find on the Microsoft website which, as usual, assumes a lot of knowledge?

(Normally I would have used C++ since I am much more experienced in that language but the task requires me to use VB where my experience is intermediate.)

Question by:jindalee
    LVL 48

    Expert Comment

    You just need to use a richtextbox control and then save as rtf like this:


    Open in new window

    LVL 1

    Author Comment

    I guess then that if I want, for example, to have some text bolded, different font etc, I have to write the code to do the bolding etc and the SaveFile method does the rest?
    LVL 48

    Accepted Solution

    Yes, that's it! You just need to add the format you want to the text and save it as a rtf file.
    Something like:
    ' bold the selection with size 12, font Arial
    Me.RichTextBox1.SelectionFont = New Font("Arial", 12, FontStyle.Bold)  
    and then save it
    LVL 1

    Author Closing Comment

    Thank you!

    I thought that the solution would be pretty simple but couldn't see it for looking. I've already checked out your suggestion and it worked first time.

    Featured Post

    Highfive + Dolby Voice = No More Audio Complaints!

    Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

    Join & Write a Comment

    Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
    For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK ( for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
    This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA.…
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!

    731 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

    15 Experts available now in Live!

    Get 1:1 Help Now