c# create word document vb.net create word document
To create a word file, first import the word lib
microsoft.office.interop.word
we must then create 3 objects
1)word application
2)word document
3) word para
then create the application
then add a document to the application
and a para to the document
now we must do all these things in the background.
so the word application must not be visible.
so set the visiblity to false.
then add the text we want.
then save all
and quit the application
we have done.
Dim wa As Microsoft.Office.Interop.Word.Application
Dim wd As Microsoft.Office.Interop.Word.Document
Dim wp As Microsoft.Office.Interop.Word.Paragraph
wa = CreateObject("Word.Application")
wa.Visible = False
wd = wa.Documents.Add
wp = wd.Content.Paragraphs.Add
wp.Range.Text = "This text will be displayed in the word file"
wd.SaveAs("F:\ex\sample.docx")
wa.Quit()