示例#1
0
        private void FormatNormalParagraphs_LibertyBrand(string DocToFormat)
        {
            var application = new Word.Application();

            Word.Document document = application.Documents.Open(DocToFormat);

            int PCount = document.Content.Paragraphs.Count;

            if (PCount > 0)
            {
                for (int i = 1; i < document.Content.Paragraphs.Count; i++)
                {
                    Word.Paragraph para  = document.Content.Paragraphs[i];
                    Word.Style     style = para.get_Style() as Word.Style;

                    lblProcessing.Text = "Processing All Paragraphs...";
                    document.RemoveNumbers();

                    if (style.NameLocal == "Normal")
                    {
                        para.Range.Font.Color = Word.WdColor.wdColorBlack;
                        para.Range.Font.Size  = 11;
                        para.Range.Font.Name  = "Arial";
                        para.Range.Bold       = 0;

                        para.Range.Paragraphs.LeftIndent      = 1;
                        para.Range.Paragraphs.RightIndent     = 0;
                        para.Range.Paragraphs.OutlineLevel    = Word.WdOutlineLevel.wdOutlineLevelBodyText;
                        para.Range.Paragraphs.Alignment       = Word.WdParagraphAlignment.wdAlignParagraphJustify;
                        para.Range.Paragraphs.SpaceAfter      = 10;
                        para.Range.Paragraphs.SpaceBefore     = 0;
                        para.Range.Paragraphs.LineSpacingRule = Word.WdLineSpacing.wdLineSpaceExactly;
                    }
                }
            }
            document.Save();
            document.Close();
            application.Quit();
        }