chetan Allipur

chetan Allipur

  • NA
  • 541
  • 166.9k

How to Insert the TableOfFigures in word using VSTO.

Jun 5 2017 2:07 AM
Please anyone tell me How to Insert the TableOfFigures in word using VSTO. I am doing my own so please anyone send me the code.
 
For TableOfContents I did. I want TableOfFigures
 
fore TableOfContents here my code.
 
 
Microsoft.Office.Interop.Word.Application app = Globals.ThisAddIn.Application;
Microsoft.Office.Interop.Word.Document doc1 = app.ActiveDocument;
object val1 = comboBox1.SelectedItem;
object oUpperHeadingLevel = "1";
object oLowerHeadingLevel = val1;
object missing = null;
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("Table of Contents\n");
TableOfContents toc = doc1.TablesOfContents.Add(wordsec.Range, ref otrue, ref oUpperHeadingLevel, ref oLowerHeadingLevel, ref ofalse, ref missing,
ref otrue, ref otrue, ref missing, ref otrue, ref ofalse, ref ofalse);
Microsoft.Office.Interop.Word.Range rngTOC = toc.Range;
rngTOC.Font.Size = 12;
rngTOC.Font.Name = "Arial";
rngTOC.Font.Bold = 0;
wordsec.set_Style(WdBuiltinStyle.wdStyleNormal);
this.Hide();