TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
chetan Allipur
NA
541
168.8k
How to get the Numbered list for Heading as in word in c#.
May 5 2017 2:11 AM
I have 5 buttons like NumHeading1, NumHeading2, NumHeading3, NumHeading4, NumHeading5 below i have code for buttons.
It is relecting to text heading not for created Numbered heading buttons.
public void NumHeading1(Office.IRibbonControl control)
{
Application app = Globals.ThisAddIn.Application;
Microsoft.Office.Interop.Word.Document doc1 = app.ActiveDocument;
Selection wordSelection = Globals.ThisAddIn.Application.Selection;
ListGallery gallery = wordSelection.Application.ListGalleries[WdListGalleryType.wdOutlineNumberGallery];
ListTemplate numberedTemplate = gallery.ListTemplates[2];
Microsoft.Office.Interop.Word.Style style = doc1.Styles["Heading " + 1];
style.LinkToListTemplate(numberedTemplate, 1);
}
public void NumHeading2(Office.IRibbonControl control)
{
Application app = Globals.ThisAddIn.Application;
Microsoft.Office.Interop.Word.Document doc1 = app.ActiveDocument;
Selection wordSelection = Globals.ThisAddIn.Application.Selection;
ListGallery gallery = wordSelection.Application.ListGalleries[WdListGalleryType.wdOutlineNumberGallery];
ListTemplate numberedTemplate = gallery.ListTemplates[2];
Microsoft.Office.Interop.Word.Style style = doc1.Styles["Heading " + 2];
style.LinkToListTemplate(numberedTemplate, 2);
}
public void NumHeading3(Office.IRibbonControl control)
{
Application app = Globals.ThisAddIn.Application;
Microsoft.Office.Interop.Word.Document doc1 = app.ActiveDocument;
Selection wordSelection = Globals.ThisAddIn.Application.Selection;
ListGallery gallery = wordSelection.Application.ListGalleries[WdListGalleryType.wdOutlineNumberGallery];
ListTemplate numberedTemplate = gallery.ListTemplates[2];
Microsoft.Office.Interop.Word.Style style = doc1.Styles["Heading " + 3];
style.LinkToListTemplate(numberedTemplate, 3);
}
public void NumHeading4(Office.IRibbonControl control)
{
Application app = Globals.ThisAddIn.Application;
Microsoft.Office.Interop.Word.Document doc1 = app.ActiveDocument;
Selection wordSelection = Globals.ThisAddIn.Application.Selection;
ListGallery gallery = wordSelection.Application.ListGalleries[WdListGalleryType.wdOutlineNumberGallery];
ListTemplate numberedTemplate = gallery.ListTemplates[2];
Microsoft.Office.Interop.Word.Style style = doc1.Styles["Heading " + 4];
style.LinkToListTemplate(numberedTemplate, 4);
}
public void NumHeading5(Office.IRibbonControl control)
{
Application app = Globals.ThisAddIn.Application;
Microsoft.Office.Interop.Word.Document doc1 = app.ActiveDocument;
Selection wordSelection = Globals.ThisAddIn.Application.Selection;
ListGallery gallery = wordSelection.Application.ListGalleries[WdListGalleryType.wdOutlineNumberGallery];
ListTemplate numberedTemplate = gallery.ListTemplates[2];
Microsoft.Office.Interop.Word.Style style = doc1.Styles["Heading " + 5];
style.LinkToListTemplate(numberedTemplate, 5);
}
Reply
Answers (
0
)
How make pivot for sql data table
Fields and properties