Click here to Skip to main content
14,922,948 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm using a rich-text box in my Application. i need to save it as a Word Document.
How do i Do it .i Have already Add the Reference but it seems like it only save as a word document, but could not open in MS word
So guys please Help !!!
Thank you


Code:

C#
try
           {
               string SaveFile = "";
               saveFileDialog1.Title = "Save File";
               saveFileDialog1.FileName = "";
               saveFileDialog1.Filter = "Word Document|*.docx";
               if (saveFileDialog1.ShowDialog() != DialogResult.Cancel)
               {
                   SaveFile = saveFileDialog1.FileName;
                   textArea.SaveFile(SaveFile, RichTextBoxStreamType.UnicodePlainText);
               }
           }
           catch (Exception ex)
           {
               MessageBox.Show("I'm Sorry ! Something Went Wrong", "Error", MessageBoxButtons.RetryCancel,         MessageBoxIcon.Stop);
           }
Posted
Updated 17-Oct-11 9:44am
v3
Comments
Philippe Mori 17-Oct-11 17:13pm
   
DOCX files are not RTF file. This is probably why it fails. Maybe it could works as a DOC file (old format).
maxxxn 18-Oct-11 12:19pm
   
thanx man That works fine by replacing doc instead of docx

Use SaveFile, or share some code so that we can get what you are doing wrong.
http://msdn.microsoft.com/en-us/library/8bf5hy2e.aspx[^]
   
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900