Click here to Skip to main content
14,971,553 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi friends,

I tried to create a .doc file in VB.NET using FILE STREAM .The Contents are from RICH TEXT BOX .Now i need to change the font style and size from coding itself.


THIS IS MY CODING TO CREATE A DOC FILE:

VB
Dim fs As New FileStream("MyData.doc", FileMode.Create, FileAccess.Write)
Dim writer As New StreamWriter(fs)
writer.WriteLine("Hello")
writer.Flush()
fs.Close()
Posted
Comments
Menon Santosh 8-Mar-13 6:35am
   
Richtextbox can handle rtf format file not doc, So first save the file in rtf and then convert it into Doc file format

1 solution

Not going to work, I'm afraid.
If you want to create DOC files, with all the appropriate formatting, then you are going to need something rather more sophisticated than just Stream.WriteLine of your text. Just giving a file the ".DOC" extension does not mean that teh system handles all teh details for you. It doesn't.

There is a simple solution here: http://en.allexperts.com/q/Visual-Basic-1048/Writing-Word-file-Vb.htm[^] but it relies on you having Word installed on the machine the application runs on.
   

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