private void button1_Click(object sender, EventArgs e) { //Create word document Document document = new Document(); Section section = document.AddSection(); //page setup SetPage(section); //insert header and footer InsertHeaderAndFooter(section); //add content InsertContent(section); //encrypt document with password specified by textBox1 document.Encrypt(this.textBox1.Text); //Save doc file. document.SaveToFile("Sample.doc",FileFormat.Doc); //Launching the MS Word file. WordDocViewer("Sample.doc"); }