Hi All,
I have two buttons, one which inserts level 1 bullets and another which inserts level 2 bullets
The problem : Here if I click on the level 1 button it inserts a numbered bullet , like "1." and I click on second button , it inserts "1.1." and now if I press the first button
to insert "2 ." it inserts fine,but the second button click does not insert 2.1 ,instead it inserts "1.2" Have been stuck on it for days.Any help is much much appreciated .Thanks
This is what I have tried so far,
//to insert level -1 numbered bullets
private void button4_Click_1(object sender, RibbonControlEventArgs e)
{
Word.ListGallery listGallery = Globals.ThisAddIn.Application.ActiveDocument.Application.ListGalleries[Word.WdListGalleryType.wdOutlineNumberGallery];
oPara = oDoc.Content.Paragraphs.Add(range);
listFormat = oPara.Range.ListFormat;
this.ApplyListTemplate1(listGallery, listFormat, 1);
range.ListFormat.ListLevelNumber = 1;
}
//to insert level-2 bullets (1.1,,2.1 etc )
private void button5_Click(object sender, RibbonControlEventArgs e)
{
Word.ListGallery listGallery = Globals.ThisAddIn.Application.ActiveDocument.Application.ListGalleries[Word.WdListGalleryType.wdOutlineNumberGallery];
oPara = oDoc.Content.Paragraphs.Add(range);
listFormat = oPara.Range.ListFormat;
this.ApplyListTemplate1(listGallery, listFormat, 2);
oPara.Range.ListFormat.ListLevelNumber = 2;
}
Here is my apply list template:
private void ApplyListTemplate1(Word.ListGallery listGallery, Word.ListFormat listFormat, int level = 2)
{
listFormat.ApplyListTemplateWithLevel(
listGallery.ListTemplates[level],
ContinuePreviousList: true,
ApplyTo: Word.WdListApplyTo.wdListApplyToSelection,
DefaultListBehavior: Word.WdDefaultListBehavior.wdWord10ListBehavior,
ApplyLevel: level);
}