예제 #1
0
        public void AddTablesOfContents()
        {
            builder.MoveToBookmark("Remark");
            builder.InsertTableOfContents("\\o \"1-3\" \\h \\z \\u");
            this.doc.UpdateFields();

            // object fileName = this.SavePath;
            // Object oMissing = System.Reflection.Missing.Value;
            // Object oTrue = true;
            // Object oFalse = false;

            // if (oWord == null)
            // {
            //     oWord = new Microsoft.Office.Interop.Word.Application();
            //     oWord.Visible = false;
            // }else
            // {

            // }
            // //Microsoft.Office.Interop.Word.Application oWord = new Microsoft.Office.Interop.Word.Application();


            // word.Document doc = null;
            // try
            // {
            //     doc = oWord.Documents.Open(ref fileName,
            // ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing,
            // ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing,
            // ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing);

            // }
            // catch (Exception exx)
            // {
            //     oWord = new Microsoft.Office.Interop.Word.Application();
            //     oWord.Visible = false;
            //     doc = oWord.Documents.Open(ref fileName,
            //ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing,
            //ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing,
            //ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing);
            // }

            // //---------------------------------------------------------------------------------------------------------------------
            // oWord.Selection.Paragraphs.OutlineLevel = word.WdOutlineLevel.wdOutlineLevel2;
            // oWord.Selection.Paragraphs.OutlineLevel = word.WdOutlineLevel.wdOutlineLevel3;
            // oWord.Selection.Paragraphs.OutlineLevel = word.WdOutlineLevel.wdOutlineLevelBodyText;

            // object x = 0;
            // word.Range bookRange = null;
            // foreach (word.Bookmark bookmark in doc.Bookmarks)
            // {
            //     if (bookmark.Name == "Remark")
            //     {
            //         bookRange = bookmark.Range;
            //         break;
            //     }
            // }

            // Object oUpperHeadingLevel = "1";
            // Object oLowerHeadingLevel = "2";
            // Object oTOCTableID = "TableOfContents";
            // doc.TablesOfContents.Add(bookRange, ref oTrue, ref oUpperHeadingLevel,
            //     ref oLowerHeadingLevel, ref oMissing, ref oTOCTableID, ref oTrue,
            //     ref oTrue, ref oMissing, ref oTrue, ref oTrue, ref oTrue);
            // doc.Save();
            // doc.Close();
        }