concept Word in category .net

appears as: Word, Word
C# in Depth

This is an excerpt from Manning's book C# in Depth.

Listing 13.9. Automating Word using normal C# 4 features
Application app = new Application { Visible = true }; app.Documents.Add(); Document doc = app.ActiveDocument; Paragraph para = doc.Paragraphs.Add(); para.Range.Text = "Thank goodness for C# 4"; object filename = "demo.doc"; object format = WdSaveFormat.wdFormatDocument97; doc.SaveAs(FileName: ref filename, FileFormat: ref format); doc.Close(); app.Application.Quit();

13.2.1. The horrors of automating Word before C# 4

Our example is simple—it’s just going to start Word, create a document with a single paragraph of text, save it, and then exit. Sounds easy, right? If only that were so. The following listing shows the code required before C# 4.