示例#1
0
        private void Button2_Click(object sender, System.EventArgs e)
        {
            DateTime dated;

            dated = DateTime.Now;

            try
            {
                test = new CCWordApp();
                test.Open(ConfigurationSettings.AppSettings["WordMod"] + "template1.dot");

                test.SetAlignment("Center");
                test.GotoBookMark("Title");
                test.SetFont("Bold");
                test.InsertText(TextTitle.Text);
                test.SetFont("nothing");

                test.GotoBookMark("name");
                test.SetFont("Italic");
                test.InsertText(TextName.Text);
                test.SetFont("nothing");

                test.GotoBookMark("address");
                test.SetAlignment("Right");
                test.InsertText(dated.ToShortDateString());
                test.InsertLineBreak();
                test.InsertText(TextAddress.Text);
                test.SetFont("nothing");

                test.SaveAs(ConfigurationSettings.AppSettings["WordDoc"] + DocName.Text + ".doc");
                // Save in html format
                test.SaveAsHtml(ConfigurationSettings.AppSettings["WordDoc"] + DocName.Text + ".html");
                test.Quit();
            }

            catch (Exception exc)
            {
                StatusMessage.Text    = exc.Message;
                StatusMessage.Visible = true;
                test.Quit();
            }
        }