Charlie Calvert on Elvenware

Writing Code and Prose on Computers

Elvenware

Accessing Microsoft Office from C#

Apply the Bullets Style to Entire Document

protected void ToBullets()
 {
     SetUpListGallary();
     Word.Range range = document.Range();
     range.ListFormat.ApplyListTemplateWithLevel(
         word.ListGalleries[
         	Word.WdListGalleryType.wdBulletGallery].ListTemplates[1],
         ContinuePreviousList: true, 
         ApplyTo: Word.WdListApplyTo.wdListApplyToWholeList,
         DefaultListBehavior: 
         	Word.WdDefaultListBehavior.wdWord10ListBehavior);
 }

 private void SetUpListGallary()
 {
     int undefinedInt = (int)Word.WdConstants.wdUndefined;
     Word.ListGalleries lg = word.ListGalleries;
     Word.ListLevel level = 
     	lg[Word.WdListGalleryType.wdBulletGallery].
     		ListTemplates[1].ListLevels[1];
     char[] temp = new char[1] { (char)61623 };
     level.NumberFormat = new string(temp);
     level.TrailingCharacter = Word.WdTrailingCharacter.wdTrailingTab;
     level.NumberStyle = Word.WdListNumberStyle.wdListNumberStyleBullet;
     level.NumberPosition = word.InchesToPoints(0.25f);
     level.Alignment = Word.WdListLevelAlignment.wdListLevelAlignLeft;
     level.TextPosition = word.InchesToPoints(0.5f);
     level.TabPosition = (float)Word.WdConstants.wdUndefined;
     level.ResetOnHigher = 0;
     level.StartAt = 1;
     Word._Font font = level.Font;
     font.Bold = undefinedInt;
     font.Italic = undefinedInt;
     font.StrikeThrough = undefinedInt;
     font.Subscript = undefinedInt;
     font.Superscript = undefinedInt;
     font.Shadow = undefinedInt;
     font.Outline = undefinedInt;
     font.Emboss = undefinedInt;
     font.Engrave = undefinedInt;
     font.AllCaps = undefinedInt;
     font.Hidden = undefinedInt;
     font.Underline = (Word.WdUnderline)Word.WdConstants.wdUndefined;
     font.Color = Word.WdColor.wdColorAutomatic;
     font.Size = (float)Word.WdConstants.wdUndefined;
     font.Animation = Word.WdAnimation.wdAnimationNone;
     font.DoubleStrikeThrough = undefinedInt;
     font.Name = "Symbol";
     level.LinkedStyle = "";
     lg[Word.WdListGalleryType.wdBulletGallery].ListTemplates[1].Name = "";
 }