rich text box

rlangi05

Member
Joined
Jan 2, 2006
Messages
21
Programming Experience
1-3
I have a rich text box where I cut and paste a bulleted document to from ms word, then I save what's inside the rich text box to a file called "PolicyNarrative.doc" and then open that file in ms word.
VB.NET:
Dim MyStream As New IO.FileStream(Application.StartupPath & "\PolicyNarrative.doc", IO.FileMode.Create)
        Dim MyWriter As New IO.StreamWriter(MyStream)
        MyWriter.Write(BuildReport("Policy Name: " & StorePolicyName, "Policy Narrative"))
        MyWriter.Close()
        MyStream.Close()

        Dim StartInfo As New ProcessStartInfo
        StartInfo.FileName = "winword.exe"
        StartInfo.Arguments = "PolicyNarrative.doc"
        StartInfo.WindowStyle = ProcessWindowStyle.Maximized
        StartInfo.UseShellExecute = True

        System.Diagnostics.Process.Start(StartInfo)
but then when it opens PolicyNarrative.doc it does not retain the format, there are no bullets, just some symbols. Instead of bullets I get this symbol "Â" and its in a paragraph format and not in a list format... in other words none of the formatting was retained. Is there something I could use so I could retain as much of the formatting from what was pasted into the rich text box.
 
I don't know what you're doing in BuildReport, but StreamWriter writes plain text.
The RichTextBox has got a SaveFile method you can exploit, where you can save the formatted text.
VB.NET:
[SIZE=2]RTB.SaveFile([/SIZE][SIZE=2][COLOR=#800000]"\test.rtf"[/COLOR][/SIZE][SIZE=2], RichTextBoxStreamType.RichText)[/SIZE]

The test.rtf file opens fine in Wordpad (and Word) etc.
 
Back
Top