chetan Allipur

chetan Allipur

  • NA
  • 541
  • 167.6k

How to do custom Numbering list in word using VSTO.

Jun 19 2017 6:22 AM
Here is for Number list
 
object missing = System.Reflection.Missing.Value;
Microsoft.Office.Interop.Word.Application app = Globals.ThisAddIn.Application;
Microsoft.Office.Interop.Word.Document doc1 = app.ActiveDocument;
app.Visible = true;
// whatever is selected will be turned into a numbered list.
object n = 1;
ListTemplate template =
app.ListGalleries[WdListGalleryType.wdOutlineNumberGallery].ListTemplates.get_Item(ref n);
Microsoft.Office.Interop.Word.ListLevel level = template.ListLevels[1];
level.NumberFormat = "%1.";
level.TrailingCharacter = WdTrailingCharacter.wdTrailingTab;
level.NumberStyle = WdListNumberStyle.wdListNumberStyleArabic;
level.NumberPosition = app.InchesToPoints(0.25f);
level.Alignment = WdListLevelAlignment.wdListLevelAlignLeft;
level.TextPosition = app.InchesToPoints(0.35f);
level.TabPosition = (float)WdConstants.wdUndefined;
level.ResetOnHigher = 0;
level.StartAt = 1;
level.LinkedStyle = "";
template.Name = "";
object bContinuePrevList = true;
object applyTo = WdListApplyTo.wdListApplyToSelection;
object defBehavior = WdDefaultListBehavior.wdWord10ListBehavior;
app.Selection.Range.ListFormat.ApplyListTemplateWithLevel(
template, ref bContinuePrevList,
ref applyTo, ref defBehavior, ref missing);
 
 
But I want for all Alphabelet list, bullet, and Roman. If I use sub lists it should work. Please any can send me the code for other list its urgent for me now 

Answers (4)