1. Chapter One
2. Chapter Two
3. Chapter Three
Here is my code.
Microsoft.Office.Interop.Word.Application app = Globals.ThisAddIn.Application;
Microsoft.Office.Interop.Word.Document doc1 = app.ActiveDocument;
string sHeadingNm = doc1.Styles[WdBuiltinStyle.wdStyleHeading1].NameLocal;
Microsoft.Office.Interop.Word.Style style = null;
ListTemplate template = null;
doc1.UpdateStyles();
app.ListGalleries[WdListGalleryType.wdOutlineNumberGallery].Reset(2);
template = app.ListGalleries[WdListGalleryType.wdOutlineNumberGallery].ListTemplates[2];
Microsoft.Office.Interop.Word.ListLevel level = template.ListLevels[1];
if (level.NumberStyle == WdListNumberStyle.wdListNumberStyleBullet)
{
level.NumberStyle = WdListNumberStyle.wdListNumberStyleNone;
}
level.NumberFormat = sPrefix + "%1.";
level.TrailingCharacter = WdTrailingCharacter.wdTrailingTab;
level.NumberStyle = WdListNumberStyle.wdListNumberStyleArabic;
level.NumberPosition = app.InchesToPoints(0f);
level.Alignment = WdListLevelAlignment.wdListLevelAlignLeft;
level.TextPosition = app.InchesToPoints((float)nHeadIndent);
level.TabPosition = app.InchesToPoints((float)nHeadIndent);
level.ResetOnHigher = 0;
level.StartAt = int.Parse(sHead1No);
//level.LinkedStyle = sHeadingNm + "1";
//Microsoft.Office.Interop.Word.Style style = doc1.Styles["Heading " + 1];
style = doc1.Styles["Heading " + 1];
style.LinkToListTemplate(template, 1);
This code I am applicale for Heading 1 to 5.
Please anyone help me. Send me the code back.