chetan Allipur

chetan Allipur

  • NA
  • 541
  • 166.4k

How to add Appendix in table of contents in word using VSTO.

Jun 12 2017 3:09 AM
How to include appendix in table of contents in word using VSTO.Please anyone send me the code.
 
Here is my code
 
Microsoft.Office.Interop.Word.Application app = Globals.ThisAddIn.Application;
Microsoft.Office.Interop.Word.Document doc1 = app.ActiveDocument;
object oMissing = System.Type.Missing;
object oTrue = true;
object ofalse = false;
Selection wordsec = app.Selection;
wordsec.Font.Bold = 1;
wordsec.Font.Size = 14;
wordsec.ParagraphFormat.Alignment = WdParagraphAlignment.wdAlignParagraphCenter;
wordsec.TypeText("Appendices\n");
TableOfContents toc= doc1.TablesOfContents.Add(wordsec.Range, ref oTrue, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oTrue,
ref oTrue, ref oMissing, ref oTrue, ref oTrue, ref oTrue);
toc.TabLeader = WdTabLeader.wdTabLeaderDots;
toc.Update();
Microsoft.Office.Interop.Word.Range rngTOC = toc.Range;
rngTOC.Font.Size = 12;
rngTOC.Font.Name = "Arial";
rngTOC.Font.Bold = 0;
if (checkBoxColor.Checked == true)
{
rngTOC.Font.Color = WdColor.wdColorBlue;
}
wordsec.set_Style(WdBuiltinStyle.wdStyleNormal);
this.Hide();