File Types?

masj78

Active member
Joined
Aug 8, 2003
Messages
31
Location
Harrogate, UK
I have written a routine to save text from a RichTextBox to a file. The text is taken from Outlook and contains the original formating. However I am loosing the formating when saving it to a .TXT file and wondering if its possible to ajust my code to save it as a .DOC instead. (would save an extra cut and paste into Wordpad/Word or openwith ....)

My code is as follows:

Code:
SaveFileDialog1.Filter = "Text files(*.txt)|*.txt"
SaveFileDialog1.ShowDialog()

        If SaveFileDialog1.FileName <> "" Then

            FileOpen(1, SaveFileDialog1.FileName, OpenMode.Output)
            PrintLine(1, RichTextBox1.Text)
            FileClose(1)

        End If

Many Thanks!:rolleyes:
 
I think if you copy the formatted text from Outlook into the clipboard then paste it in the RTB it will work. Then you just use the save method of the RTB to keep the formatting.

I believe you can then give it the extention of doc.
 
Use the SaveFile and LoadFile methods of the RTB.
Also I would suggest using IO.StremReader for reading and IO.StreamWriter for writing, they are part of the framework and better then the old vb6 methods.
:)
 
Many Thanks for the advice. I have chosen to use the RTB methods, which has taken a fraction of the code and saves the files with no loss of formating:

Code:
Private Sub cmdSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdSave.Click

SaveFileDialog1.Filter = "Text files(*.doc)|*.doc"
SaveFileDialog1.ShowDialog()
emailText.SaveFile(SaveFileDialog1.FileName,OpenMode.Output)

End Sub

cheers!
 
Back
Top